From d599bbc73718375a2f64ff3b4d16e19251e2968a Mon Sep 17 00:00:00 2001 From: 07akioni <07akioni2@gmail.com> Date: Sat, 9 Jan 2021 01:43:48 +0800 Subject: [PATCH] refactor: affix -> collapse, theme peers & overrides --- .../components/avatar/enUS/color.demo.md | 12 +- .../components/avatar/zhCN/color.demo.md | 12 +- src/_base/README.md | 1 + src/_base/icon/index.js | 1 + src/_base/icon/src/Icon.vue | 16 ++ src/_base/icon/src/styles/index.cssr.js | 16 ++ src/_base/index.js | 1 + src/_base/select-menu/src/SelectMenu.vue | 7 +- src/_base/selection/src/Selection.vue | 1 + src/_base/slot-machine/src/SlotMachine.vue | 16 +- src/_mixins/use-theme.js | 4 +- src/_mixins/with-cssr.js | 183 ++++++++++++++ src/affix/src/Affix.vue | 6 +- src/affix/src/styles/index.cssr.js | 21 +- src/alert/src/Alert.vue | 53 ++--- src/alert/src/styles/index.cssr.js | 38 +-- src/alert/styles/dark.js | 5 + src/alert/styles/light.js | 5 + src/anchor/src/AnchorAdapter.vue | 56 ++++- src/anchor/src/BaseAnchor.vue | 36 +-- src/anchor/styles/dark.js | 7 +- src/anchor/styles/light.js | 4 + src/auto-complete/src/AutoComplete.vue | 15 +- src/auto-complete/styles/dark.js | 7 +- src/auto-complete/styles/light.js | 7 +- src/avatar/src/Avatar.vue | 20 +- src/avatar/styles/dark.js | 1 + src/avatar/styles/light.js | 1 + src/back-top/src/BackTop.vue | 22 +- src/back-top/src/styles/index.cssr.js | 42 ++-- src/back-top/src/styles/index.js | 9 - src/back-top/styles/dark.js | 4 +- src/back-top/styles/light.js | 4 +- src/badge/src/Badge.vue | 12 +- src/badge/styles/dark.js | 5 +- src/badge/styles/light.js | 5 +- src/breadcrumb/src/Breadcrumb.vue | 6 +- src/breadcrumb/src/BreadcrumbItem.vue | 6 +- src/breadcrumb/styles/dark.js | 1 + src/breadcrumb/styles/light.js | 1 + src/button/src/Button.vue | 15 +- src/card/src/Card.vue | 14 +- src/card/src/styles/index.cssr.js | 3 +- src/card/styles/dark.js | 5 +- src/card/styles/light.js | 5 +- src/cascader/src/Cascader.vue | 19 +- src/cascader/src/CascaderMenu.vue | 12 +- src/cascader/src/CascaderOption.vue | 10 +- src/cascader/src/CascaderSelectMenu.vue | 10 +- src/cascader/src/CascaderSubmenu.vue | 12 +- src/cascader/src/styles/index.cssr.js | 225 +++++++++--------- src/cascader/styles/dark.js | 3 +- src/cascader/styles/light.js | 3 +- src/checkbox/src/Checkbox.vue | 4 +- src/checkbox/styles/dark.js | 3 +- src/checkbox/styles/light.js | 3 +- src/code/src/styles/index.cssr.js | 3 +- src/code/styles/dark.js | 1 + src/code/styles/light.js | 1 + src/collapse/src/Collapse.js | 8 +- src/collapse/src/CollapseItem.vue | 16 +- src/collapse/src/CollapseItemContent.js | 6 +- src/collapse/src/styles/index.cssr.js | 157 ++++++------ src/collapse/src/styles/index.js | 9 - src/collapse/styles/dark.js | 5 +- src/collapse/styles/light.js | 5 +- src/select/src/Select.vue | 6 +- src/styles.js | 30 +-- src/styles.new.js | 5 +- 69 files changed, 729 insertions(+), 538 deletions(-) create mode 100644 src/_base/icon/index.js create mode 100644 src/_base/icon/src/Icon.vue create mode 100644 src/_base/icon/src/styles/index.cssr.js create mode 100644 src/_mixins/with-cssr.js delete mode 100644 src/back-top/src/styles/index.js delete mode 100644 src/collapse/src/styles/index.js diff --git a/demo/documentation/components/avatar/enUS/color.demo.md b/demo/documentation/components/avatar/enUS/color.demo.md index 2b146ca65..e452fd061 100644 --- a/demo/documentation/components/avatar/enUS/color.demo.md +++ b/demo/documentation/components/avatar/enUS/color.demo.md @@ -1,19 +1,13 @@ # Color -Color is depend on you even in different theme. You can set it to something related to things you want to eat. +You can set it to something related to things you want to eat. ```html M ``` diff --git a/demo/documentation/components/avatar/zhCN/color.demo.md b/demo/documentation/components/avatar/zhCN/color.demo.md index a1afc2421..cb0110eb0 100644 --- a/demo/documentation/components/avatar/zhCN/color.demo.md +++ b/demo/documentation/components/avatar/zhCN/color.demo.md @@ -1,19 +1,13 @@ # 颜色 -颜色可以对不同主题分别设定的,你可以把它设成某种和你爱吃的东西有关的颜色。 +你可以把它设成某种和你爱吃的东西有关的颜色。 ```html M ``` diff --git a/src/_base/README.md b/src/_base/README.md index 6209f6053..20595e9fc 100644 --- a/src/_base/README.md +++ b/src/_base/README.md @@ -3,3 +3,4 @@ Themeable components: - selection - select-menu - clear-button +- close diff --git a/src/_base/icon/index.js b/src/_base/icon/index.js new file mode 100644 index 000000000..58128242a --- /dev/null +++ b/src/_base/icon/index.js @@ -0,0 +1 @@ +export { default } from './src/Icon.vue' diff --git a/src/_base/icon/src/Icon.vue b/src/_base/icon/src/Icon.vue new file mode 100644 index 000000000..109d41dc6 --- /dev/null +++ b/src/_base/icon/src/Icon.vue @@ -0,0 +1,16 @@ + + + diff --git a/src/_base/icon/src/styles/index.cssr.js b/src/_base/icon/src/styles/index.cssr.js new file mode 100644 index 000000000..c7359c9c6 --- /dev/null +++ b/src/_base/icon/src/styles/index.cssr.js @@ -0,0 +1,16 @@ +import { c, cB } from '../../../../_utils/cssr' + +export default cB('base-icon', ` + height: 1em; + width: 1em; + line-height: 1em; + text-align: center; + display: inline-block; + position: relative; + fill: currentColor; +`, [ + c('svg', { + height: '1em', + width: '1em' + }) +]) diff --git a/src/_base/index.js b/src/_base/index.js index 23ba446e9..088e36c42 100644 --- a/src/_base/index.js +++ b/src/_base/index.js @@ -8,3 +8,4 @@ export { default as NBaseMenuMask } from './menu-mask' export { default as NBaseSelection } from './selection' export { default as NBaseSlotMachine } from './slot-machine' export { default as NBaseClearButton } from './clear-button' +export { default as NBaseIcon } from './icon' diff --git a/src/_base/select-menu/src/SelectMenu.vue b/src/_base/select-menu/src/SelectMenu.vue index 59ea335a8..39776f66d 100644 --- a/src/_base/select-menu/src/SelectMenu.vue +++ b/src/_base/select-menu/src/SelectMenu.vue @@ -69,7 +69,7 @@ diff --git a/src/_base/selection/src/Selection.vue b/src/_base/selection/src/Selection.vue index 718f5b0d5..de8a242e4 100644 --- a/src/_base/selection/src/Selection.vue +++ b/src/_base/selection/src/Selection.vue @@ -178,6 +178,7 @@ export default defineComponent({ NTag }, props: { + ...useTheme.props, bordered: { type: Boolean, default: undefined diff --git a/src/_base/slot-machine/src/SlotMachine.vue b/src/_base/slot-machine/src/SlotMachine.vue index 1cdb84abb..7a50afd72 100644 --- a/src/_base/slot-machine/src/SlotMachine.vue +++ b/src/_base/slot-machine/src/SlotMachine.vue @@ -1,5 +1,5 @@ diff --git a/src/alert/src/styles/index.cssr.js b/src/alert/src/styles/index.cssr.js index e35e5700b..841de13be 100644 --- a/src/alert/src/styles/index.cssr.js +++ b/src/alert/src/styles/index.cssr.js @@ -15,14 +15,14 @@ import fadeInHeightExpandTranstion from '../../../_styles/transitions/fade-in-he // --border-radius // --font-size // --title-font-weight -export default cB('alert', { - lineHeight: 'var(--line-height)', - borderRadius: 'var(--border-radius)', - position: 'relative', - transition: 'background-color .3s var(--bezier)', - backgroundColor: 'var(--color)', - textAlign: 'start' -}, [ +export default cB('alert', ` + line-height: var(--line-height); + border-radius: var(--border-radius); + position: relative; + transition: background-color .3s var(--bezier); + background-color: var(--color); + text-align: start; +`, [ cE('close', { color: 'var(--close-color)' }, [ @@ -82,17 +82,17 @@ export default cB('alert', { cursor: 'pointer' }) ]), - cB('alert-body', { - borderRadius: 'var(--border-radius)', - padding: '15px 15px 15px 47px', - transition: 'border-color .3s var(--bezier)' - }, [ - cE('title', { - transition: 'color .3s var(--bezier)', - fontSize: '16px', - lineHeight: '19px', - fontWeight: 'var(--title-font-weight)' - }, [ + cB('alert-body', ` + border-radius: var(--border-radius); + padding: 15px 15px 15px 47px; + transition: border-color .3s var(--bezier); + `, [ + cE('title', ` + transition: color .3s var(--bezier); + font-size: 16px; + line-height: 19px; + font-weight: var(--title-font-weight); + `, [ c('& +', [ cE('content', { marginTop: '9px' diff --git a/src/alert/styles/dark.js b/src/alert/styles/dark.js index 53dfeb580..21dc694ba 100644 --- a/src/alert/styles/dark.js +++ b/src/alert/styles/dark.js @@ -1,8 +1,13 @@ import { changeColor } from 'seemly' import { commonDark } from '../../_styles/new-common' +import { iconDark } from '../../icon/styles' export default { + name: 'Alert', common: commonDark, + peers: { + Icon: iconDark + }, self (vars) { const { lineHeight, diff --git a/src/alert/styles/light.js b/src/alert/styles/light.js index 5fdc61bb2..de62d2140 100644 --- a/src/alert/styles/light.js +++ b/src/alert/styles/light.js @@ -1,8 +1,13 @@ import { changeColor, composite } from 'seemly' +import { iconLight } from '../../icon/styles' import { commonLight } from '../../_styles/new-common' export default { + name: 'Alert', common: commonLight, + peers: { + Icon: iconLight + }, self (vars) { const { lineHeight, diff --git a/src/anchor/src/AnchorAdapter.vue b/src/anchor/src/AnchorAdapter.vue index 0e3d56422..904f249b0 100644 --- a/src/anchor/src/AnchorAdapter.vue +++ b/src/anchor/src/AnchorAdapter.vue @@ -1,7 +1,8 @@