From 90bbda47b2b7750b0ceaf763be7cc813b5224785 Mon Sep 17 00:00:00 2001 From: srgooglo Date: Fri, 7 Aug 2020 23:10:43 +0200 Subject: [PATCH] update: theme runtime --- .umirc.ts => .umirc.js | 28 +- package.json | 5 +- src/pages/debug/antd.js | 17 + src/pages/debug/theme.js | 2 +- src/theme/antd-theme.less | 1 + src/theme/base/antd-design.less | 851 -------------------------------- src/theme/base/index.less | 76 ++- src/theme/base/vars.less | 65 ++- src/theme/index.js | 7 + tsconfig.json | 2 +- 10 files changed, 121 insertions(+), 933 deletions(-) rename .umirc.ts => .umirc.js (77%) create mode 100644 src/pages/debug/antd.js create mode 100644 src/theme/antd-theme.less delete mode 100644 src/theme/base/antd-design.less create mode 100644 src/theme/index.js diff --git a/.umirc.ts b/.umirc.js similarity index 77% rename from .umirc.ts rename to .umirc.js index 241115f7..ed1a8528 100644 --- a/.umirc.ts +++ b/.umirc.js @@ -1,10 +1,25 @@ import { defineConfig } from 'umi'; -const fs = require('fs'); -const path = require('path'); -const lessToJs = require('less-vars-to-js'); +const Path = require('path'); const { resolve } = require('path'); +const themePth = require('./src/theme/index.js') +const lessToJs = require('less-vars-to-js'); +const fs = require('fs'); +const AntDesignThemePlugin = require('antd-theme-webpack-plugin'); + +const options = { + antDir: Path.join(__dirname, './node_modules/antd'), + stylesDir: Path.join(__dirname, './src/styles'), + varFile: Path.join(__dirname, './src/styles/variables.less'), + themeVariables: ['@primary-color'], + indexFileName: 'index.html' +} + +const themePlugin = new AntDesignThemePlugin(options); + + +const convToVars = file => lessToJs(fs.readFileSync(Path.join(__dirname, file), 'utf8')) export default defineConfig({ hash: false, ignoreMomentLocale: true, @@ -13,11 +28,11 @@ export default defineConfig({ loading: 'components/Loader/Loader.js', }, dva: { immer: true }, - antd: {}, nodeModulesTransform: { type: 'none', }, alias: { + antd: resolve(__dirname, './node_modules/antd'), api: resolve(__dirname, './node_modules/@ragestudio/ycorejs-lib'), globals: resolve(__dirname, './globals'), core: resolve(__dirname, './src/core'), @@ -27,9 +42,6 @@ export default defineConfig({ models: resolve(__dirname, './src/models'), routes: resolve(__dirname, './src/routes'), }, - theme: lessToJs( - fs.readFileSync(path.join(__dirname, './src/theme/index.less'), 'utf8'), - ), extraBabelPlugins: [ [ 'import', @@ -41,7 +53,7 @@ export default defineConfig({ 'lodash', ], ], - + // plugins: [themePlugin], // chainWebpack: function(config, { webpack }) { // config.module // .rule('js-in-node_modules') diff --git a/package.json b/package.json index b4afbc62..607c1a7a 100755 --- a/package.json +++ b/package.json @@ -39,15 +39,11 @@ "antd": "^4.5.1", "axios": "^0.19.2", "babel-core": "^6.26.3", - "big-json": "^3.1.0", "classnames": "^2.2.6", - "colorthief": "^2.3.0", "dva-model-extend": "^0.1.2", - "dva-react-hook": "^1.2.7", "enquire-js": "^0.2.1", "feather-reactjs": "^2.0.13", "jquery": "^3.5.1", - "jsdoc": "^3.6.5", "less-vars-to-js": "^1.3.0", "lint-staged": "^10.0.7", "localforage": "^1.7.4", @@ -89,6 +85,7 @@ "babel-plugin-module-resolver": "^4.0.0", "cross-env": "^6.0.0", "typescript": "^3.8.3", + "jsdoc": "^3.6.5", "umi": "^3.2.9" } } diff --git a/src/pages/debug/antd.js b/src/pages/debug/antd.js new file mode 100644 index 00000000..f3d6fa48 --- /dev/null +++ b/src/pages/debug/antd.js @@ -0,0 +1,17 @@ +import React from 'react' +import themeStyle from 'theme/base/vars.less' + +class AntdDebug extends React.Component{ + state = { + styleLink: document.getElementById('theme-style'), + body: document.getElementsByTagName('body')[0] + } + render(){ + return( +
+ {JSON.stringify(themeStyle)} +
+ ) + } +} +export default AntdDebug \ No newline at end of file diff --git a/src/pages/debug/theme.js b/src/pages/debug/theme.js index ed51cf58..843fb04c 100644 --- a/src/pages/debug/theme.js +++ b/src/pages/debug/theme.js @@ -70,7 +70,7 @@ export default class themedebug extends React.PureComponent {

Sample text

- + diff --git a/src/theme/antd-theme.less b/src/theme/antd-theme.less new file mode 100644 index 00000000..77899efb --- /dev/null +++ b/src/theme/antd-theme.less @@ -0,0 +1 @@ +@import '~antd/dist/antd.dark.less'; // Introduce the official dark less style entry file diff --git a/src/theme/base/antd-design.less b/src/theme/base/antd-design.less deleted file mode 100644 index 5a2528c7..00000000 --- a/src/theme/base/antd-design.less +++ /dev/null @@ -1,851 +0,0 @@ -/* stylelint-disable at-rule-empty-line-before,at-rule-name-space-after,at-rule-no-unknown */ -@import '../../../node_modules/antd/lib/style/themes/default.less'; - -// -------- Colors ----------- -@primary-color: #fff; -@info-color: @blue-6; -@success-color: @green-6; -@processing-color: @blue-6; -@error-color: @red-6; -@highlight-color: @red-6; -@warning-color: @gold-6; -@normal-color: #d9d9d9; -@white: #fff; -@black: #000; - -// Color used by default to control hover and active backgrounds and for -// alert info backgrounds. -@primary-1: color( - ~`colorPalette('@{primary-color}', 1) ` -); // replace tint(@primary-color, 90%) -@primary-2: color( - ~`colorPalette('@{primary-color}', 2) ` -); // replace tint(@primary-color, 80%) -@primary-3: color(~`colorPalette('@{primary-color}', 3) `); // unused -@primary-4: color(~`colorPalette('@{primary-color}', 4) `); // unused -@primary-5: color( - ~`colorPalette('@{primary-color}', 5) ` -); // color used to control the text color in many active and hover states, replace tint(@primary-color, 20%) -@primary-6: @primary-color; // color used to control the text color of active buttons, don't use, use @primary-color -@primary-7: color( - ~`colorPalette('@{primary-color}', 7) ` -); // replace shade(@primary-color, 5%) -@primary-8: color(~`colorPalette('@{primary-color}', 8) `); // unused -@primary-9: color(~`colorPalette('@{primary-color}', 9) `); // unused -@primary-10: color(~`colorPalette('@{primary-color}', 10) `); // unused - -// Base Scaffolding Variables -// --- - -// Background color for `` -@body-background: rgb(249, 249, 249); -// Base background color for most components -@component-background: #fff; -@font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', - 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, - sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; -@code-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, - monospace; -@text-color: fade(@black, 65%); -@text-color-Overlay: fade(@black, 45%); -@text-color-inverse: @white; -@icon-color: inherit; -@icon-color-hover: fade(@black, 75%); -@heading-color: fade(#000, 85%); -@heading-color-dark: fade(@white, 100%); -@text-color-dark: fade(@white, 85%); -@text-color-Overlay-dark: fade(@white, 65%); -@text-selection-bg: @primary-color; -@font-variant-base: tabular-nums; -@font-feature-settings-base: 'tnum'; -@font-size-base: 14px; -@font-size-lg: @font-size-base + 2px; -@font-size-sm: 12px; -@heading-1-size: ceil(@font-size-base * 2.71); -@heading-2-size: ceil(@font-size-base * 2.14); -@heading-3-size: ceil(@font-size-base * 1.71); -@heading-4-size: ceil(@font-size-base * 1.42); -@line-height-base: 1.5; -@border-radius-base: 4px; -@border-radius-sm: 2px; - -// vertical paddings -@padding-lg: 24px; // containers -@padding-md: 16px; // small containers and buttons -@padding-sm: 12px; // Form controls and items -@padding-xs: 8px; // small items - -// vertical padding for all form controls -@control-padding-horizontal: @padding-sm; -@control-padding-horizontal-sm: @padding-xs; - -// The background colors for active and hover states for things like -// list items or table cells. -@item-active-bg: @primary-1; -@item-hover-bg: @primary-1; - -// ICONFONT -@iconfont-css-prefix: anticon; - -// LINK -@link-color: @primary-color; -@link-hover-color: color(~`colorPalette('@{link-color}', 5) `); -@link-active-color: color(~`colorPalette('@{link-color}', 7) `); -@link-decoration: none; -@link-hover-decoration: none; - -// Animation -@ease-base-out: cubic-bezier(0.7, 0.3, 0.1, 1); -@ease-base-in: cubic-bezier(0.9, 0, 0.3, 0.7); -@ease-out: cubic-bezier(0.215, 0.61, 0.355, 1); -@ease-in: cubic-bezier(0.55, 0.055, 0.675, 0.19); -@ease-in-out: cubic-bezier(0.645, 0.045, 0.355, 1); -@ease-out-back: cubic-bezier(0.12, 0.4, 0.29, 1.46); -@ease-in-back: cubic-bezier(0.71, -0.46, 0.88, 0.6); -@ease-in-out-back: cubic-bezier(0.71, -0.46, 0.29, 1.46); -@ease-out-circ: cubic-bezier(0.08, 0.82, 0.17, 1); -@ease-in-circ: cubic-bezier(0.6, 0.04, 0.98, 0.34); -@ease-in-out-circ: cubic-bezier(0.78, 0.14, 0.15, 0.86); -@ease-out-quint: cubic-bezier(0.23, 1, 0.32, 1); -@ease-in-quint: cubic-bezier(0.755, 0.05, 0.855, 0.06); -@ease-in-out-quint: cubic-bezier(0.86, 0, 0.07, 1); - -// Border color -@border-color-base: hsv(0, 0, 85%); // base border outline a component -@border-color-split: hsv(0, 0, 91%); // split border inside a component -@border-color-inverse: @white; -@border-width-base: 1px; // width of the border for a component -@border-style-base: solid; // style of a components border - -// Outline -@outline-blur-size: 0; -@outline-width: 2px; -@outline-color: @primary-color; - -@background-color-light: hsv( - 0, - 0, - 98% -); // background of header and selected item -@background-color-base: hsv(0, 0, 96%); // Default grey background color - -// Disabled states -@disabled-color: fade(#000, 25%); -@disabled-bg: @background-color-base; -@disabled-color-dark: fade(#fff, 35%); - -// Shadow -@shadow-color: rgba(0, 0, 0, 0.15); -@shadow-color-inverse: @component-background; -@box-shadow-base: @shadow-1-down; -@shadow-1-up: 0 -2px 8px @shadow-color; -@shadow-1-down: 0 2px 8px @shadow-color; -@shadow-1-left: -2px 0 8px @shadow-color; -@shadow-1-right: 2px 0 8px @shadow-color; -@shadow-2: 0 4px 12px @shadow-color; - -// Buttons -@btn-font-weight: 400; -@btn-border-radius-base: @border-radius-base; -@btn-border-radius-sm: @border-radius-base; -@btn-border-width: @border-width-base; -@btn-border-style: @border-style-base; -@btn-shadow: 0 2px 0 rgba(0, 0, 0, 0.015); -@btn-primary-shadow: 0 2px 0 rgba(0, 0, 0, 0.045); -@btn-text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.12); - -@btn-primary-color: #fff; -@btn-primary-bg: @primary-color; - -@btn-default-color: @text-color; -@btn-default-bg: @component-background; -@btn-default-border: @border-color-base; - -@btn-danger-color: #fff; -@btn-danger-bg: color(~`colorPalette('@{error-color}', 5) `); -@btn-danger-border: color(~`colorPalette('@{error-color}', 5) `); - -@btn-disable-color: @disabled-color; -@btn-disable-bg: @disabled-bg; -@btn-disable-border: @border-color-base; - -@btn-padding-base: 0 @padding-md - 1px; -@btn-font-size-lg: @font-size-lg; -@btn-font-size-sm: @font-size-base; -@btn-padding-lg: @btn-padding-base; -@btn-padding-sm: 0 @padding-xs - 1px; - -@btn-height-base: 32px; -@btn-height-lg: 40px; -@btn-height-sm: 24px; - -@btn-circle-size: @btn-height-base; -@btn-circle-size-lg: @btn-height-lg; -@btn-circle-size-sm: @btn-height-sm; - -@btn-square-size: @btn-height-base; -@btn-square-size-lg: @btn-height-lg; -@btn-square-size-sm: @btn-height-sm; - -@btn-group-border: @primary-5; - -// Checkbox -@checkbox-size: 16px; -@checkbox-color: @primary-color; -@checkbox-check-color: #fff; -@checkbox-border-width: @border-width-base; - -// Descriptions -@descriptions-bg: #fafafa; - -// Dropdown -@dropdown-selected-color: @primary-color; - -// Empty -@empty-font-size: @font-size-base; - -// Radio -@radio-size: 16px; -@radio-dot-color: @primary-color; - -// Radio buttons -@radio-button-bg: @btn-default-bg; -@radio-button-checked-bg: @btn-default-bg; -@radio-button-color: @btn-default-color; -@radio-button-hover-color: @primary-5; -@radio-button-active-color: @primary-7; - -// Media queries breakpoints -// Extra small screen / phone -@screen-xs: 480px; -@screen-xs-min: @screen-xs; - -// Small screen / tablet -@screen-sm: 576px; -@screen-sm-min: @screen-sm; - -// Medium screen / desktop -@screen-md: 768px; -@screen-md-min: @screen-md; - -// Large screen / wide desktop -@screen-lg: 992px; -@screen-lg-min: @screen-lg; - -// Extra large screen / full hd -@screen-xl: 1200px; -@screen-xl-min: @screen-xl; - -// Extra extra large screen / large desktop -@screen-xxl: 1600px; -@screen-xxl-min: @screen-xxl; - -// provide a maximum -@screen-xs-max: (@screen-sm-min - 1px); -@screen-sm-max: (@screen-md-min - 1px); -@screen-md-max: (@screen-lg-min - 1px); -@screen-lg-max: (@screen-xl-min - 1px); -@screen-xl-max: (@screen-xxl-min - 1px); - -// Grid system -@grid-columns: 24; -@grid-gutter-width: 0; - -// Layout -@layout-body-background: #f0f2f5; -@layout-header-background: #424242; -@layout-footer-background: @layout-body-background; -@layout-header-height: 64px; -@layout-header-padding: 0 50px; -@layout-footer-padding: 24px 50px; -@layout-sider-background: @layout-header-background; -@layout-trigger-height: 48px; -@layout-trigger-background: #2d2d2d; -@layout-trigger-color: #fff; -@layout-zero-trigger-width: 36px; -@layout-zero-trigger-height: 42px; -// Layout light theme -@layout-sider-background-light: #fff; -@layout-trigger-background-light: #fff; -@layout-trigger-color-light: @text-color; - -// z-index list, order by `z-index` -@zindex-table-fixed: auto; -@zindex-affix: 10; -@zindex-back-top: 10; -@zindex-badge: 10; -@zindex-picker-panel: 10; -@zindex-popup-close: 10; -@zindex-modal: 1000; -@zindex-modal-mask: 1000; -@zindex-message: 1010; -@zindex-notification: 1010; -@zindex-popover: 1030; -@zindex-dropdown: 1050; -@zindex-picker: 1050; -@zindex-tooltip: 1060; - -// Animation -@animation-duration-slow: 0.3s; // Modal -@animation-duration-base: 0.2s; -@animation-duration-fast: 0.1s; // Tooltip - -//CollapsePanel -@collapse-panel-border-radius: @border-radius-base; - -//Dropdown -@dropdown-vertical-padding: 5px; -@dropdown-font-size: @font-size-base; -@dropdown-line-height: 22px; - -// Form -// --- -@label-required-color: @highlight-color; -@label-color: @heading-color; -@form-warning-input-bg: @input-bg; -@form-item-margin-bottom: 24px; -@form-item-trailing-colon: true; -@form-vertical-label-padding: 0 0 8px; -@form-vertical-label-margin: 0; -@form-item-label-colon-margin-right: 8px; -@form-item-label-colon-margin-left: 2px; -@form-error-input-bg: @input-bg; - -// Input -// --- -@input-height-base: 32px; -@input-height-lg: 40px; -@input-height-sm: 24px; -@input-padding-horizontal: @control-padding-horizontal - 1px; -@input-padding-horizontal-base: @input-padding-horizontal; -@input-padding-horizontal-sm: @control-padding-horizontal-sm - 1px; -@input-padding-horizontal-lg: @input-padding-horizontal; -@input-padding-vertical-base: 4px; -@input-padding-vertical-sm: 1px; -@input-padding-vertical-lg: 6px; -@input-placeholder-color: hsv(0, 0, 75%); -@input-color: @text-color; -@input-border-color: @border-color-base; -@input-bg: @component-background; -@input-number-handler-active-bg: #f4f4f4; -@input-number-handler-hover-bg: @primary-5; -@input-number-handler-bg: @component-background; -@input-number-handler-border-color: @border-color-base; -@input-addon-bg: @background-color-light; -@input-hover-border-color: @primary-5; -@input-disabled-bg: @disabled-bg; -@input-outline-offset: 0 0; - -// Select -// --- -@select-border-color: @border-color-base; -@select-item-selected-font-weight: 600; -@select-dropdown-bg: @component-background; -@select-item-selected-bg: @background-color-light; -@select-item-active-bg: @item-active-bg; - -// Anchor -// --- -@anchor-border-color: @border-color-split; - -// Tooltip -// --- -// Tooltip max width -@tooltip-max-width: 250px; -// Tooltip text color -@tooltip-color: #fff; -// Tooltip background color -@tooltip-bg: rgba(0, 0, 0, 0.75); -// Tooltip arrow width -@tooltip-arrow-width: 5px; -// Tooltip distance with trigger -@tooltip-distance: @tooltip-arrow-width - 1px + 4px; -// Tooltip arrow color -@tooltip-arrow-color: @tooltip-bg; - -// Popover -// --- -// Popover body background color -@popover-bg: @component-background; -// Popover text color -@popover-color: @text-color; -// Popover maximum width -@popover-min-width: 177px; -// Popover arrow width -@popover-arrow-width: 6px; -// Popover arrow color -@popover-arrow-color: @popover-bg; -// Popover outer arrow width -// Popover outer arrow color -@popover-arrow-outer-color: @popover-bg; -// Popover distance with trigger -@popover-distance: @popover-arrow-width + 4px; - -// Modal -// -- -@modal-body-padding: 24px; -@modal-header-bg: @component-background; -@modal-footer-bg: transparent; -@modal-footer-border-color-split: @border-color-split; -@modal-mask-bg: fade(@black, 45%); - -// Progress -// -- -@progress-default-color: @processing-color; -@progress-remaining-color: @background-color-base; -@progress-text-color: @text-color; -@progress-radius: 100px; - -// Menu -// --- -@menu-inline-toplevel-item-height: 40px; -@menu-item-height: 40px; -@menu-collapsed-width: 80px; -@menu-bg: @component-background; -@menu-popup-bg: @component-background; -@menu-item-color: @text-color; -@menu-highlight-color: @primary-color; -@menu-item-active-bg: @item-active-bg; -@menu-item-active-border-width: 3px; -@menu-item-group-title-color: @text-color-Overlay; -@menu-icon-size: @font-size-base; -@menu-icon-size-lg: @font-size-lg; - -@menu-item-vertical-margin: 4px; -@menu-item-font-size: @font-size-base; -@menu-item-boundary-margin: 8px; -@menu-icon-size: @font-size-base; -@menu-icon-size-lg: @font-size-lg; -@menu-dark-selected-item-icon-color: @white; -@menu-dark-selected-item-text-color: @white; -@dark-menu-item-hover-bg: transparent; - -// dark theme -@menu-dark-color: @text-color-Overlay-dark; -@menu-dark-bg: #2d2d2d; -@menu-dark-arrow-color: #fff; -@menu-dark-submenu-bg: #2d2d2d; -@menu-dark-highlight-color: #fff; -@menu-dark-item-active-bg: @primary-color; -@menu-dark-selected-item-icon-color: @white; -@menu-dark-selected-item-text-color: @white; -@menu-dark-item-hover-bg: transparent; -// Spin -// --- -@spin-dot-size-sm: 14px; -@spin-dot-size: 20px; -@spin-dot-size-lg: 32px; - -// Table -// -- -@table-header-bg: @background-color-light; -@table-header-color: @heading-color; -@table-header-sort-bg: @background-color-base; -@table-body-sort-bg: rgba(0, 0, 0, 0.01); -@table-row-hover-bg: @primary-1; -@table-selected-row-color: inherit; -@table-selected-row-bg: #fafafa; -@table-body-selected-sort-bg: @table-selected-row-bg; -@table-selected-row-hover-bg: @table-selected-row-bg; -@table-expanded-row-bg: #fbfbfb; -@table-padding-vertical: 16px; -@table-padding-horizontal: 16px; -@table-border-radius-base: @border-radius-base; -@table-footer-bg: @background-color-light; -@table-footer-color: @heading-color; - -// Tag -// -- -@tag-default-bg: @background-color-light; -@tag-default-color: @text-color; -@tag-font-size: @font-size-sm; - -// TimePicker -// --- -@time-picker-panel-column-width: 56px; -@time-picker-panel-width: @time-picker-panel-column-width * 3; -@time-picker-selected-bg: @background-color-base; - -// Carousel -// --- -@carousel-dot-width: 16px; -@carousel-dot-height: 3px; -@carousel-dot-active-width: 24px; - -// Badge -// --- -@badge-height: 20px; -@badge-dot-size: 6px; -@badge-font-size: @font-size-sm; -@badge-font-weight: normal; -@badge-status-size: 6px; -@badge-text-color: @component-background; - -// Rate -// --- -@rate-star-color: @yellow-6; -@rate-star-bg: @border-color-split; - -// Card -// --- -@card-head-color: @heading-color; -@card-head-background: transparent; -@card-head-padding: 16px; -@card-inner-head-padding: 12px; -@card-padding-base: 24px; -@card-actions-background: @background-color-light; -@card-skeleton-bg: #cfd8dc; -@card-background: @component-background; -@card-shadow: 0 2px 8px rgba(0, 0, 0, 0.09); -@card-radius: @border-radius-sm; - -// Comment -// --- -@comment-padding-base: 16px 0; -@comment-nest-indent: 44px; -@comment-font-size-base: @font-size-base; -@comment-font-size-sm: @font-size-sm; -@comment-author-name-color: @text-color-Overlay; -@comment-author-time-color: #ccc; -@comment-action-color: @text-color-Overlay; -@comment-action-hover-color: #595959; - -// Tabs -// --- -@tabs-card-head-background: @background-color-light; -@tabs-card-height: 40px; -@tabs-card-active-color: @primary-color; -@tabs-title-font-size: @font-size-base; -@tabs-title-font-size-lg: @font-size-lg; -@tabs-title-font-size-sm: @font-size-base; -@tabs-ink-bar-color: @primary-color; -@tabs-bar-margin: 0 0 16px 0; -@tabs-horizontal-margin: 0 32px 0 0; -@tabs-horizontal-padding: 12px 16px; -@tabs-horizontal-padding-lg: 16px; -@tabs-horizontal-padding-sm: 8px 16px; -@tabs-vertical-padding: 8px 24px; -@tabs-vertical-margin: 0 0 16px 0; -@tabs-scrolling-size: 32px; -@tabs-highlight-color: @primary-color; -@tabs-hover-color: @primary-5; -@tabs-active-color: @primary-7; -@tabs-card-gutter: 2px; -@tabs-card-tab-active-border-top: 2px solid transparent; - -// BackTop -// --- -@back-top-color: #fff; -@back-top-bg: @text-color-Overlay; -@back-top-hover-bg: @text-color; - -// Avatar -// --- -@avatar-size-base: 32px; -@avatar-size-lg: 40px; -@avatar-size-sm: 24px; -@avatar-font-size-base: 18px; -@avatar-font-size-lg: 24px; -@avatar-font-size-sm: 14px; -@avatar-bg: #ccc; -@avatar-color: #fff; -@avatar-border-radius: @border-radius-base; - -// Switch -// --- -@switch-height: 22px; -@switch-sm-height: 16px; -@switch-sm-checked-margin-left: -(@switch-sm-height - 3px); -@switch-disabled-opacity: 0.4; -@switch-color: @primary-color; -@switch-shadow-color: fade(#00230b, 20%); - -// Pagination -// --- -@pagination-item-size: 32px; -@pagination-item-size-sm: 24px; -@pagination-font-family: Arial; -@pagination-font-weight-active: 500; -@pagination-item-bg-active: @component-background; - -// PageHeader -// --- -@page-header-padding: 24px; -@page-header-padding-vertical: 16px; -@page-header-padding-breadcrumb: 12px; -@page-header-back-color: #000; - -// Breadcrumb -// --- -@breadcrumb-base-color: @text-color-Overlay; -@breadcrumb-last-item-color: @text-color; -@breadcrumb-font-size: @font-size-base; -@breadcrumb-icon-font-size: @font-size-base; -@breadcrumb-link-color: @text-color-Overlay; -@breadcrumb-link-color-hover: @primary-5; -@breadcrumb-separator-color: @text-color-Overlay; -@breadcrumb-separator-margin: 0 @padding-xs; - -// Slider -// --- -@slider-margin: 14px 6px 10px; -@slider-rail-background-color: @background-color-base; -@slider-rail-background-color-hover: #e1e1e1; -@slider-track-background-color: @primary-3; -@slider-track-background-color-hover: @primary-4; -@slider-handle-border-width: 2px; -@slider-handle-background-color: @component-background; -@slider-handle-color: @primary-3; -@slider-handle-color-hover: @primary-4; -@slider-handle-color-focus: tint(@primary-color, 20%); -@slider-handle-color-focus-shadow: fade(@primary-color, 20%); -@slider-handle-color-tooltip-open: @primary-color; -@slider-handle-shadow: 0; -@slider-dot-border-color: @border-color-split; -@slider-dot-border-color-active: tint(@primary-color, 50%); -@slider-disabled-color: @disabled-color; -@slider-disabled-background-color: @component-background; - -// Tree -// --- -@tree-title-height: 24px; -@tree-child-padding: 18px; -@tree-directory-selected-color: #fff; -@tree-directory-selected-bg: @primary-color; -@tree-node-hover-bg: @item-hover-bg; -@tree-node-selected-bg: @primary-2; - -// Collapse -// --- -@collapse-header-padding: 12px 16px; -@collapse-header-padding-extra: 40px; -@collapse-header-bg: @background-color-light; -@collapse-content-padding: @padding-md; -@collapse-content-bg: @component-background; - -// Skeleton -// --- -@skeleton-color: #f2f2f2; - -// Transfer -// --- -@transfer-header-height: 40px; -@transfer-disabled-bg: @disabled-bg; -@transfer-list-height: 200px; - -// Message -// --- -@message-notice-content-padding: 10px 16px; - -// Motion -// --- -@wave-animation-width: 6px; - -// Alert -// --- -@alert-success-border-color: ~`colorPalette('@{success-color}', 3) `; -@alert-success-bg-color: ~`colorPalette('@{success-color}', 1) `; -@alert-success-icon-color: @success-color; -@alert-info-border-color: ~`colorPalette('@{info-color}', 3) `; -@alert-info-bg-color: ~`colorPalette('@{info-color}', 1) `; -@alert-info-icon-color: @info-color; -@alert-warning-border-color: ~`colorPalette('@{warning-color}', 3) `; -@alert-warning-bg-color: ~`colorPalette('@{warning-color}', 1) `; -@alert-warning-icon-color: @warning-color; -@alert-error-border-color: ~`colorPalette('@{error-color}', 3) `; -@alert-error-bg-color: ~`colorPalette('@{error-color}', 1) `; -@alert-error-icon-color: @error-color; - -// List -// --- -@list-header-background: transparent; -@list-footer-background: transparent; -@list-empty-text-padding: @padding-md; -@list-item-padding: @padding-sm 0; -@list-item-meta-margin-bottom: @padding-md; -@list-item-meta-avatar-margin-right: @padding-md; -@list-item-meta-title-margin-bottom: @padding-sm; - -// Statistic -// --- -@statistic-title-font-size: @font-size-base; -@statistic-content-font-size: 24px; -@statistic-unit-font-size: 16px; -@statistic-font-family: @font-family; - -// Drawer -// --- -@drawer-header-padding: 16px 24px; -@drawer-body-padding: 24px; - -// Timeline -// --- -@timeline-width: 2px; -@timeline-color: @border-color-split; -@timeline-dot-border-width: 2px; -@timeline-dot-color: @primary-color; -@timeline-dot-bg: @component-background; - -// Typography -// --- -@typography-title-font-weight: 600; -@typography-title-margin-top: 1.2em; -@typography-title-margin-bottom: 0.5em; - -// color palettes -@blue-1: color(~`colorPalette('@{blue-6}', 1) `); -@blue-2: color(~`colorPalette('@{blue-6}', 2) `); -@blue-3: color(~`colorPalette('@{blue-6}', 3) `); -@blue-4: color(~`colorPalette('@{blue-6}', 4) `); -@blue-5: color(~`colorPalette('@{blue-6}', 5) `); -@blue-6: #1890ff; -@blue-7: color(~`colorPalette('@{blue-6}', 7) `); -@blue-8: color(~`colorPalette('@{blue-6}', 8) `); -@blue-9: color(~`colorPalette('@{blue-6}', 9) `); -@blue-10: color(~`colorPalette('@{blue-6}', 10) `); - -@purple-1: color(~`colorPalette('@{purple-6}', 1) `); -@purple-2: color(~`colorPalette('@{purple-6}', 2) `); -@purple-3: color(~`colorPalette('@{purple-6}', 3) `); -@purple-4: color(~`colorPalette('@{purple-6}', 4) `); -@purple-5: color(~`colorPalette('@{purple-6}', 5) `); -@purple-6: #722ed1; -@purple-7: color(~`colorPalette('@{purple-6}', 7) `); -@purple-8: color(~`colorPalette('@{purple-6}', 8) `); -@purple-9: color(~`colorPalette('@{purple-6}', 9) `); -@purple-10: color(~`colorPalette('@{purple-6}', 10) `); - -@cyan-1: color(~`colorPalette('@{cyan-6}', 1) `); -@cyan-2: color(~`colorPalette('@{cyan-6}', 2) `); -@cyan-3: color(~`colorPalette('@{cyan-6}', 3) `); -@cyan-4: color(~`colorPalette('@{cyan-6}', 4) `); -@cyan-5: color(~`colorPalette('@{cyan-6}', 5) `); -@cyan-6: #13c2c2; -@cyan-7: color(~`colorPalette('@{cyan-6}', 7) `); -@cyan-8: color(~`colorPalette('@{cyan-6}', 8) `); -@cyan-9: color(~`colorPalette('@{cyan-6}', 9) `); -@cyan-10: color(~`colorPalette('@{cyan-6}', 10) `); - -@green-1: color(~`colorPalette('@{green-6}', 1) `); -@green-2: color(~`colorPalette('@{green-6}', 2) `); -@green-3: color(~`colorPalette('@{green-6}', 3) `); -@green-4: color(~`colorPalette('@{green-6}', 4) `); -@green-5: color(~`colorPalette('@{green-6}', 5) `); -@green-6: #52c41a; -@green-7: color(~`colorPalette('@{green-6}', 7) `); -@green-8: color(~`colorPalette('@{green-6}', 8) `); -@green-9: color(~`colorPalette('@{green-6}', 9) `); -@green-10: color(~`colorPalette('@{green-6}', 10) `); - -@magenta-1: color(~`colorPalette('@{magenta-6}', 1) `); -@magenta-2: color(~`colorPalette('@{magenta-6}', 2) `); -@magenta-3: color(~`colorPalette('@{magenta-6}', 3) `); -@magenta-4: color(~`colorPalette('@{magenta-6}', 4) `); -@magenta-5: color(~`colorPalette('@{magenta-6}', 5) `); -@magenta-6: #eb2f96; -@magenta-7: color(~`colorPalette('@{magenta-6}', 7) `); -@magenta-8: color(~`colorPalette('@{magenta-6}', 8) `); -@magenta-9: color(~`colorPalette('@{magenta-6}', 9) `); -@magenta-10: color(~`colorPalette('@{magenta-6}', 10) `); - -// alias of magenta -@pink-1: color(~`colorPalette('@{pink-6}', 1) `); -@pink-2: color(~`colorPalette('@{pink-6}', 2) `); -@pink-3: color(~`colorPalette('@{pink-6}', 3) `); -@pink-4: color(~`colorPalette('@{pink-6}', 4) `); -@pink-5: color(~`colorPalette('@{pink-6}', 5) `); -@pink-6: #eb2f96; -@pink-7: color(~`colorPalette('@{pink-6}', 7) `); -@pink-8: color(~`colorPalette('@{pink-6}', 8) `); -@pink-9: color(~`colorPalette('@{pink-6}', 9) `); -@pink-10: color(~`colorPalette('@{pink-6}', 10) `); - -@red-1: color(~`colorPalette('@{red-6}', 1) `); -@red-2: color(~`colorPalette('@{red-6}', 2) `); -@red-3: color(~`colorPalette('@{red-6}', 3) `); -@red-4: color(~`colorPalette('@{red-6}', 4) `); -@red-5: color(~`colorPalette('@{red-6}', 5) `); -@red-6: #f5222d; -@red-7: color(~`colorPalette('@{red-6}', 7) `); -@red-8: color(~`colorPalette('@{red-6}', 8) `); -@red-9: color(~`colorPalette('@{red-6}', 9) `); -@red-10: color(~`colorPalette('@{red-6}', 10) `); - -@orange-1: color(~`colorPalette('@{orange-6}', 1) `); -@orange-2: color(~`colorPalette('@{orange-6}', 2) `); -@orange-3: color(~`colorPalette('@{orange-6}', 3) `); -@orange-4: color(~`colorPalette('@{orange-6}', 4) `); -@orange-5: color(~`colorPalette('@{orange-6}', 5) `); -@orange-6: #fa8c16; -@orange-7: color(~`colorPalette('@{orange-6}', 7) `); -@orange-8: color(~`colorPalette('@{orange-6}', 8) `); -@orange-9: color(~`colorPalette('@{orange-6}', 9) `); -@orange-10: color(~`colorPalette('@{orange-6}', 10) `); - -@yellow-1: color(~`colorPalette('@{yellow-6}', 1) `); -@yellow-2: color(~`colorPalette('@{yellow-6}', 2) `); -@yellow-3: color(~`colorPalette('@{yellow-6}', 3) `); -@yellow-4: color(~`colorPalette('@{yellow-6}', 4) `); -@yellow-5: color(~`colorPalette('@{yellow-6}', 5) `); -@yellow-6: #fadb14; -@yellow-7: color(~`colorPalette('@{yellow-6}', 7) `); -@yellow-8: color(~`colorPalette('@{yellow-6}', 8) `); -@yellow-9: color(~`colorPalette('@{yellow-6}', 9) `); -@yellow-10: color(~`colorPalette('@{yellow-6}', 10) `); - -@volcano-1: color(~`colorPalette('@{volcano-6}', 1) `); -@volcano-2: color(~`colorPalette('@{volcano-6}', 2) `); -@volcano-3: color(~`colorPalette('@{volcano-6}', 3) `); -@volcano-4: color(~`colorPalette('@{volcano-6}', 4) `); -@volcano-5: color(~`colorPalette('@{volcano-6}', 5) `); -@volcano-6: #fa541c; -@volcano-7: color(~`colorPalette('@{volcano-6}', 7) `); -@volcano-8: color(~`colorPalette('@{volcano-6}', 8) `); -@volcano-9: color(~`colorPalette('@{volcano-6}', 9) `); -@volcano-10: color(~`colorPalette('@{volcano-6}', 10) `); - -@geekblue-1: color(~`colorPalette('@{geekblue-6}', 1) `); -@geekblue-2: color(~`colorPalette('@{geekblue-6}', 2) `); -@geekblue-3: color(~`colorPalette('@{geekblue-6}', 3) `); -@geekblue-4: color(~`colorPalette('@{geekblue-6}', 4) `); -@geekblue-5: color(~`colorPalette('@{geekblue-6}', 5) `); -@geekblue-6: #2f54eb; -@geekblue-7: color(~`colorPalette('@{geekblue-6}', 7) `); -@geekblue-8: color(~`colorPalette('@{geekblue-6}', 8) `); -@geekblue-9: color(~`colorPalette('@{geekblue-6}', 9) `); -@geekblue-10: color(~`colorPalette('@{geekblue-6}', 10) `); - -@lime-1: color(~`colorPalette('@{lime-6}', 1) `); -@lime-2: color(~`colorPalette('@{lime-6}', 2) `); -@lime-3: color(~`colorPalette('@{lime-6}', 3) `); -@lime-4: color(~`colorPalette('@{lime-6}', 4) `); -@lime-5: color(~`colorPalette('@{lime-6}', 5) `); -@lime-6: #a0d911; -@lime-7: color(~`colorPalette('@{lime-6}', 7) `); -@lime-8: color(~`colorPalette('@{lime-6}', 8) `); -@lime-9: color(~`colorPalette('@{lime-6}', 9) `); -@lime-10: color(~`colorPalette('@{lime-6}', 10) `); - -@gold-1: color(~`colorPalette('@{gold-6}', 1) `); -@gold-2: color(~`colorPalette('@{gold-6}', 2) `); -@gold-3: color(~`colorPalette('@{gold-6}', 3) `); -@gold-4: color(~`colorPalette('@{gold-6}', 4) `); -@gold-5: color(~`colorPalette('@{gold-6}', 5) `); -@gold-6: #faad14; -@gold-7: color(~`colorPalette('@{gold-6}', 7) `); -@gold-8: color(~`colorPalette('@{gold-6}', 8) `); -@gold-9: color(~`colorPalette('@{gold-6}', 9) `); -@gold-10: color(~`colorPalette('@{gold-6}', 10) `); - -@preset-colors: pink, magenta, red, volcano, orange, yellow, gold, cyan, lime, - green, blue, geekblue, purple; - -@border-radius-base: 3px; -@border-radius-sm: 2px; -@shadow-color: rgba(0, 0, 0, 0.05); -@shadow-1-down: 4px 4px 40px @shadow-color; -@border-color-split: #f4f4f4; -@border-color-base: #e5e5e5; -@font-size-base: 13px; -@text-color: #666; -@hover-color: #f9f9fc; diff --git a/src/theme/base/index.less b/src/theme/base/index.less index 7a9ea174..630d2902 100644 --- a/src/theme/base/index.less +++ b/src/theme/base/index.less @@ -1,4 +1,7 @@ -@import './antd-design.less'; +// @import '../../../node_modules/antd/lib/style/themes/dark.less'; +// @import '../../../node_modules/antd/dist/antd.dark.css'; +@import '../../../node_modules/antd/lib/style/themes/dark.less'; + @import './vars.less'; @import './fonts-import.css'; @@ -11,44 +14,6 @@ @import './components/Menssaging.less'; @import './components/PostCard.less'; -@AppTheme_global_color_accent: rgb(162, 162, 162); - -@AppTheme_global_color: rgb(51, 51, 51); -@AppTheme_global_background: rgb(248, 246, 248); - -@AppTheme_global_color_dark: rgb(162, 162, 162); -@AppTheme_global_background_dark: rgb(51, 51, 51); - -@__Global_general_font_family: "Poppins", sans-serif; -@__Global_texted_font: "Manrope", sans-serif; -@__Global_alternative_font: "Netflix Sans", sans-serif; - -@__Global_layout_backgroud: #F8F6F8; -@__Global_layout_color: #2d2d2d; -@__Global_layout_border-rd: 27px 0 0 0; -@__Global_layout_transitions-dur: 200ms; -@__Global_Components_transitions_dur: 150ms; - -@__Global_SwapAnimDuration: 170ms; -@__Global_backdrop_backgroud: rgba(158, 158, 158, 0.5); - -@app_accent_gradient: linear-gradient(90deg, rgba(237,111,86,1) 0%, rgba(234,89,89,1) 100%); - -@transition-ease-in: all 0.3s ease-out; -@transition-ease-out: all 0.3s ease-out; -@transition-ease-inout: all 150ms ease-in-out; - - -@Overlay_wrapper_hidden_width: 22vw; -@Overlay_wrapper_showFull_width: 94.2%; -@Overlay_wrapper_showHalf_width: 35vw; - - -@Overlay_container_1_btn_backgroud: #4c4c4c; -@Overlay_container_1_btn_color: #fff; -@Overlay_container_1_btn_shadow: 0px 0px 10px 0px rgba(255, 255, 255, 0.205); - - ::-webkit-scrollbar { position: absolute; width: 14px; @@ -87,11 +52,11 @@ width: 100vw; transition: all @__Global_Components_transitions_dur linear; - + &.dark_mode{ color: @AppTheme_global_color_dark!important; background-color: @AppTheme_global_background_dark!important; - + :global{ .ant-card{ background: @AppTheme_global_background_dark!important; @@ -123,7 +88,7 @@ body { line-height: @base-line-height; font-family: @__Global_texted_font; - + } @media (max-width: @bp-small){ @@ -145,10 +110,35 @@ body { } @media (min-width: @bp-xxlarge) { - + } +.text-overflow { + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; +} + +.text-gradient { + background-image: -webkit-gradient( + linear, + 37.219838% 34.532506%, + 36.425669% 93.178216%, + from(#29cdff), + to(#0a60ff), + color-stop(0.37, #148eff) + ); + -webkit-background-clip: text; + -webkit-text-fill-color: transparent; +} + +.background-hover { + transition: @transition-ease-in; + &:hover { + background-color: @hover-color; + } +} diff --git a/src/theme/base/vars.less b/src/theme/base/vars.less index 3c6990fd..10f4fbef 100644 --- a/src/theme/base/vars.less +++ b/src/theme/base/vars.less @@ -1,3 +1,43 @@ + +@AppTheme_global_color_accent: rgb(162, 162, 162); + +@AppTheme_global_color: rgb(51, 51, 51); +@AppTheme_global_background: rgb(248, 246, 248); + +@AppTheme_global_color_dark: rgb(162, 162, 162); +@AppTheme_global_background_dark: rgb(51, 51, 51); + +@__Global_general_font_family: "Poppins", sans-serif; +@__Global_texted_font: "Manrope", sans-serif; +@__Global_alternative_font: "Netflix Sans", sans-serif; + +@__Global_layout_backgroud: #F8F6F8; +@__Global_layout_color: #2d2d2d; +@__Global_layout_border-rd: 27px 0 0 0; +@__Global_layout_transitions-dur: 200ms; +@__Global_Components_transitions_dur: 150ms; + +@__Global_SwapAnimDuration: 170ms; +@__Global_backdrop_backgroud: rgba(158, 158, 158, 0.5); + +@app_accent_gradient: linear-gradient(90deg, rgba(237,111,86,1) 0%, rgba(234,89,89,1) 100%); + +@transition-ease-in: all 0.3s ease-out; +@transition-ease-out: all 0.3s ease-out; +@transition-ease-inout: all 150ms ease-in-out; + + +@Overlay_wrapper_hidden_width: 22vw; +@Overlay_wrapper_showFull_width: 94.2%; +@Overlay_wrapper_showHalf_width: 35vw; + + +@Overlay_container_1_btn_backgroud: #4c4c4c; +@Overlay_container_1_btn_color: #fff; +@Overlay_container_1_btn_shadow: 0px 0px 10px 0px rgba(255, 255, 255, 0.205); + + + @border-radius-base: 3px; @border-radius-sm: 2px; @shadow-color: rgba(0, 0, 0, 0.05); @@ -15,28 +55,3 @@ @transition-ease-out: all 0.3s ease-out; @ease-in: ease-in; -.text-overflow { - white-space: nowrap; - text-overflow: ellipsis; - overflow: hidden; -} - -.text-gradient { - background-image: -webkit-gradient( - linear, - 37.219838% 34.532506%, - 36.425669% 93.178216%, - from(#29cdff), - to(#0a60ff), - color-stop(0.37, #148eff) - ); - -webkit-background-clip: text; - -webkit-text-fill-color: transparent; -} - -.background-hover { - transition: @transition-ease-in; - &:hover { - background-color: @hover-color; - } -} diff --git a/src/theme/index.js b/src/theme/index.js new file mode 100644 index 00000000..77b4b0cf --- /dev/null +++ b/src/theme/index.js @@ -0,0 +1,7 @@ +const { resolve } = require('path'); +const lessToJs = require('less-vars-to-js'); +const fs = require('fs'); + +const convToVars = file => lessToJs(fs.readFileSync(resolve(__dirname, file), 'utf8')) + +module.exports = convToVars('./antd-theme.less') \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 7576cde8..4562cdbb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,7 +19,7 @@ "mock/**/*", "src/**/*", "config/**/*", - ".umirc.ts", + ".umirc.js", "typings.d.ts" ] }