mirror of
https://github.com/RabbyHub/Rabby.git
synced 2026-01-12 08:48:02 -05:00
* style: add dark mode about css vars. * feat: support reactive theme mode. * feat: try to apply dark mode on dashboard/send-token. * feat: support dark mode for NFTView. * feat: checkout partial from bg-state-hooks feature to support reactive theme mode. * feat: basic support dark mode for More. * feat: only enable dark mode on DEBUG. * feat: basic support dark mode for Current Address. * feat: basic support of dark mode for address-management about workflow * feat: basic dark mode support for entry of hardware wallet connect. * feat: parital support of dark mode for send-token about workflow. * style: for themMode, swap light's value with system's. * feat: parital support of dark mode for approval. * fix: some icons' size, normalize all default value of `--r-neutral-foot` as light mode. * fix: props assigned to svg component. * feat: parital support of dark mode for entry of swap & signature. * style: tuning styles for address/txs/send about UI. * style: tuning style for swap about UIs. * style: tuning for Token Selector * style: tuning for Swap Quotes. * style: tuning for Sort Address popup. * fix: normalize isDarkOnSystem for both css/icon. * feat: support dark mode for all sub popup/pages from 'More'(Settings) * style: little fix. * fix: darkmode support for NFT UIs * style: darkmode tuning for Add-an-address & ChainSelector-button * style: update icon's color on More popup. * style: support dark mode for import-my-metamask * style: tuning darkmode for signText approval. * style: tuning darkmode for addr management. * style: tuning darkmode for complex sign approval. * style: fix some style on darkmode. * style: support darkmode for asset list in dashboard. * style: fix some cases on darkmode. * chore: little fix. * chore: robust change. * feat: support darkmode on Unlock page. * fix: constant. * fix: darkmode support for safe type address. * feat: changelog and pending approval modal * fix: dork mode for safe and cobo safe * fix: safe nonce selector * fix: input style in Unlock page. * fix: wallet brand logo's display on manage-address header & del-address-modal. * fix: keystone icon * style: dark mode tuning. * feat: lock to light mode for Tab page on production. * style: dark mode tuning. * style: dark mode fix. * chore: style tuning. * style: update most colors to opaque version. * chore: style tuning. * feat: coinbase keyring * chore: update keyring * fix: border width * fix: make linter happy * fix: connected * fix: remove resetConnect * chore: update keyring * fix: connect * chore: update keyring * fix: coinbase light icon * style: dark mode tuning. * feat: enable theme switch entry. * chore: code cleanup. * style: fix and dark mode tuning. * chore: style tuning. * style: tuning style for security level. * fix: sign waiting style on darkmode. * style: fix. * style: fix style on dark mode. * style: dark mode tuning. * chore: style tuning. * feat: + changelog --------- Co-authored-by: vvvvvv1vvvvvv <galennnnnnn@gmail.com> Co-authored-by: heisenberg <heisenberg-2077@outlook.com>
121 lines
3.5 KiB
JavaScript
121 lines
3.5 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const lessVarsToJs = require('less-vars-to-js');
|
|
const tinycolor2 = require('tinycolor2');
|
|
|
|
const { themeColors, rabbyCssPrefix } = require('../src/constant/theme-colors');
|
|
|
|
const ROOT = path.resolve(__dirname, '..');
|
|
|
|
const cssvarSrcfile = path.resolve(ROOT, 'src/ui/style/cssvars.css');
|
|
|
|
const SPACES = ` `;
|
|
const LINE_BREAK = '\n';
|
|
|
|
const SPECIAL_DEFAULT_ALPHA = {
|
|
light: [],
|
|
dark: [],
|
|
}
|
|
|
|
makeCssVar: {
|
|
const cssvarSrcContent = `
|
|
/* this file is genetared automatically, never modify it manually! */
|
|
:root {
|
|
--rabby-color-opacity: 1;
|
|
--tw-bg-opacity: 1;
|
|
|
|
/* -------------------- base define -------------------- */
|
|
${['light', 'dark'].map(theme => {
|
|
return Object.entries(themeColors[theme]).map(([cssvarKey, colorValue]) => {
|
|
const varcore = cssvarKey.replace(/^\-\-/, '');
|
|
|
|
return `${SPACES}--rabby-${theme}-${varcore}: ${colorValue};`;
|
|
}).join(LINE_BREAK)
|
|
}).join(LINE_BREAK.repeat(2))}
|
|
}
|
|
|
|
${[
|
|
{
|
|
theme: 'light',
|
|
parentSelector: ':root',
|
|
},
|
|
{
|
|
theme: 'dark',
|
|
parentSelector: 'html.dark, body.dark',
|
|
}
|
|
].map(({ theme, parentSelector }) => {
|
|
const isDarkTheme = theme === 'dark';
|
|
|
|
return `${parentSelector} {
|
|
${SPACES}/* -------------------- ${theme} mode -------------------- */
|
|
${Object.entries(themeColors[theme]).map(([cssvarKey, colorValue]) => {
|
|
const varcore = cssvarKey.replace(/^\-\-/, '');
|
|
|
|
const tinyColor = tinycolor2(colorValue);
|
|
const rgbs = tinyColor.toRgb();
|
|
const alpha = tinyColor.getAlpha();
|
|
if (alpha !== 1) {
|
|
SPECIAL_DEFAULT_ALPHA[theme].push({ cssvarKey, alpha });
|
|
}
|
|
|
|
return [
|
|
`${SPACES}--${rabbyCssPrefix}${cssvarKey}-rgb: ${rgbs.r}, ${rgbs.g}, ${rgbs.b};`,
|
|
// `${SPACES}--${rabbyCssPrefix}${cssvarKey}-opacity: ${alpha};`,
|
|
// `${SPACES}--${rabbyCssPrefix}${cssvarKey}: rgba(${rgbs.r}, ${rgbs.g}, ${rgbs.b}, var(--${rabbyCssPrefix}${cssvarKey}-opacity, 1));`,
|
|
`${SPACES}--${rabbyCssPrefix}${cssvarKey}: var(--rabby-${theme}-${varcore});`,
|
|
].filter(Boolean).join(LINE_BREAK);
|
|
}).join(LINE_BREAK)}
|
|
}
|
|
${!SPECIAL_DEFAULT_ALPHA[theme].length ? '' : SPECIAL_DEFAULT_ALPHA[theme].map(({ cssvarKey, alpha }) => {
|
|
return [
|
|
// `${isDarkTheme ? `.dark ` : ''} {
|
|
// ${SPACES}--${rabbyCssPrefix}${cssvarKey}-opacity: ${alpha};
|
|
// }`,
|
|
// `${isDarkTheme ? `.dark ` : ''}.bg-${rabbyCssPrefix}${cssvarKey} {
|
|
// ${SPACES}--bg-${rabbyCssPrefix}${cssvarKey}-opacity: ${alpha};
|
|
// }`,
|
|
].filter(Boolean).join(LINE_BREAK);
|
|
}).filter(Boolean).join(LINE_BREAK)}`
|
|
}).join(LINE_BREAK)}
|
|
`;
|
|
fs.writeFileSync(cssvarSrcfile, cssvarSrcContent, 'utf8');
|
|
|
|
console.log('[rabby] make-theme css vars version success!');
|
|
}
|
|
|
|
makeVarsInJs: {
|
|
const varsLess = fs.readFileSync(path.resolve(ROOT, './src/ui/style/var.less'), 'utf8');
|
|
|
|
const palette = lessVarsToJs(varsLess, {
|
|
resolveVariables: true,
|
|
stripPrefix: false
|
|
});
|
|
|
|
Object.entries(palette).forEach(([key, value]) => {
|
|
palette[key] = value.trim()
|
|
.replace(/\r\n/g, '')
|
|
.replace(/\n/g, '');
|
|
});
|
|
|
|
const fname = path.basename(__filename);
|
|
|
|
fs.writeFileSync(path.resolve(ROOT, './src/ui/style/var-defs.ts'), `\
|
|
/* eslint-disable */
|
|
/* this file is genetared by ${fname} automatically, never modify it manually! */
|
|
const LessPalette = ${JSON.stringify(palette, null, ' ')};
|
|
|
|
export function ellipsis(){
|
|
return \`
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
\`
|
|
}
|
|
|
|
export default LessPalette;
|
|
`);
|
|
|
|
console.log('[rabby] make-theme js version success!');
|
|
} |