
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
@nftfyorg/antd-theme-vars
Advanced tools
Since Ant Design does not have a way to handle theme switch. This package will scan your theme folder and generate css and theme vars to override your less variables.
Since Ant Design does not have a way to handle theme switch. This package will scan your theme folder and generate css and theme vars to override your less variables.
dark.less
@primary-color: #000000;
light.less
@primary-color: #AAAAAA;
Output theme.css:
.light {
--primary-color: #AAAAAA;
}
.dark {
--primary-color: #000000;
}
Output theme.vars:
{
['primary-color']: 'var(--primary-color);'
}
example: src/themes/dark.less
@primary-color: red; // primary color for all components
@gray-1: #ffffff;
@gray-2: #fafafa;
@gray-3: #f5f5f5;
@gray-4: #f0f0f0;
@gray-5: #d9d9d9;
@gray-6: #bfbfbf;
@gray-7: #8c8c8c;
@gray-8: #595959;
@gray-9: #434343;
@gray-10: #262626;
{
"themesPath": "src/themes"
}
const withLess = require('next-with-less')
// only server side
const { theme } = require('antd-theme-vars')
// ...
const nextConfig = {
// ...
publicRuntimeConfig: {
theme: theme.vars // optionally only if you want to use available vars on client-side.
},
// ....
}
// ...
module.exports = withLess({
...nextConfig,
lessLoaderOptions: {
// it will add your themes by context, eg: .dark { --primary-color: red; } .light { --primary-color: yellow; }
additionalData: theme.css,
lessOptions: {
// it will modify less vars, eg: { ['primary-color']: '--var(--primary-color)' }
modifyVars: theme.vars,
javascriptEnabled: true,
}
}
})
...
example: src/themes/Theme.tsx
import getConfig from 'next/config';
import { ReactNode, useState } from 'react';
import { ThemeProvider as StyledThemeProvider } from 'styled-components';
export interface ThemeProviderProps {
children: ReactNode
}
export function ThemeProvider({ children }: ThemeProviderProps) {
const { publicRuntimeConfig } = getConfig()
const [dark, setIsDark] = useState(false)
return (
<StyledThemeProvider theme={publicRuntimeConfig.theme || {}}>
<div className={dark ? 'dark': 'light'}>
<button onClick={() => setIsDark(!dark)}>Toggle theme</button>
{children}
</div>
</StyledThemeProvider>
)
}
FAQs
Since Ant Design does not have a way to handle theme switch. This package will scan your theme folder and generate css and theme vars to override your less variables.
The npm package @nftfyorg/antd-theme-vars receives a total of 0 weekly downloads. As such, @nftfyorg/antd-theme-vars popularity was classified as not popular.
We found that @nftfyorg/antd-theme-vars demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.