From 0147b34f878235280e01caccfc3529c6ad9f8842 Mon Sep 17 00:00:00 2001 From: 07akioni <07akioni2@gmail.com> Date: Sun, 3 Jan 2021 23:42:04 +0800 Subject: [PATCH] refactor(grid): new theme --- src/grid/src/Col.vue | 39 ++++++++++++----------- src/grid/src/Row.vue | 41 ++++++++++++++----------- src/grid/src/styles/base.cssr.js | 51 ------------------------------- src/grid/src/styles/index.cssr.js | 48 +++++++++++++++++++++++++++++ src/grid/src/styles/index.js | 9 ------ src/grid/styles/dark.js | 12 ++------ src/grid/styles/light.js | 12 ++------ src/styles.js | 2 +- src/styles.new.js | 4 ++- 9 files changed, 100 insertions(+), 118 deletions(-) delete mode 100644 src/grid/src/styles/base.cssr.js create mode 100644 src/grid/src/styles/index.cssr.js delete mode 100644 src/grid/src/styles/index.js diff --git a/src/grid/src/Col.vue b/src/grid/src/Col.vue index c42af7953..28b642f62 100644 --- a/src/grid/src/Col.vue +++ b/src/grid/src/Col.vue @@ -3,8 +3,8 @@ class="n-col" :class="{ [`n-col--${span}-span`]: true, - [`n-col--${computedPush}-push`]: computedPush > 0, - [`n-col--${-computedPush}-pull`]: computedPush < 0, + [`n-col--${mergedPush}-push`]: mergedPush > 0, + [`n-col--${-mergedPush}-pull`]: mergedPush < 0, [`n-col--${offset}-offset`]: offset }" :style="{ @@ -21,15 +21,13 @@ diff --git a/src/grid/src/Row.vue b/src/grid/src/Row.vue index efc0eea31..0f255fd3b 100644 --- a/src/grid/src/Row.vue +++ b/src/grid/src/Row.vue @@ -16,14 +16,14 @@ diff --git a/src/grid/src/styles/base.cssr.js b/src/grid/src/styles/base.cssr.js deleted file mode 100644 index 6afce9069..000000000 --- a/src/grid/src/styles/base.cssr.js +++ /dev/null @@ -1,51 +0,0 @@ -import { c, cB, cM, cE } from '../../../_utils/cssr' - -export default c([ - () => { - return cB('row', { - width: '100%' - }, - [ - cM('flex', { - display: 'flex' - }) - ]) - }, - () => { - const positionStyles = Array - .apply(null, { length: 24 }) - .map((_, index) => { - const prefixIndex = index + 1 - const percent = (1 / 24 * prefixIndex * 100).toFixed(2) + '%' - return [ - cM(`${prefixIndex}-span`, { - width: percent - }), - cM(`${prefixIndex}-offset`, { - marginLeft: percent - }), - cM(`${prefixIndex}-push`, { - left: percent - }), - cM(`${prefixIndex}-pull`, { - right: percent - }) - ] - }) - return cB('col', { - verticalAlign: 'top', - boxSizing: 'border-box', - display: 'inline-block', - position: 'relative', - zIndex: 'auto' - }, [ - cE('box', { - position: 'relative', - zIndex: 'auto', - width: '100%', - height: '100%' - }), - positionStyles - ]) - } -]) diff --git a/src/grid/src/styles/index.cssr.js b/src/grid/src/styles/index.cssr.js new file mode 100644 index 000000000..3624c760d --- /dev/null +++ b/src/grid/src/styles/index.cssr.js @@ -0,0 +1,48 @@ +import { c, cB, cM, cE } from '../../../_utils/cssr' + +const positionStyles = Array + .apply(null, { length: 24 }) + .map((_, index) => { + const prefixIndex = index + 1 + const percent = (1 / 24 * prefixIndex * 100).toFixed(2) + '%' + return [ + cM(`${prefixIndex}-span`, { + width: percent + }), + cM(`${prefixIndex}-offset`, { + marginLeft: percent + }), + cM(`${prefixIndex}-push`, { + left: percent + }), + cM(`${prefixIndex}-pull`, { + right: percent + }) + ] + }) + +export default c([ + cB('row', { + width: '100%' + }, + [ + cM('flex', { + display: 'flex' + }) + ]), + cB('col', { + verticalAlign: 'top', + boxSizing: 'border-box', + display: 'inline-block', + position: 'relative', + zIndex: 'auto' + }, [ + cE('box', { + position: 'relative', + zIndex: 'auto', + width: '100%', + height: '100%' + }), + positionStyles + ]) +]) diff --git a/src/grid/src/styles/index.js b/src/grid/src/styles/index.js deleted file mode 100644 index 72ffee344..000000000 --- a/src/grid/src/styles/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import baseStyle from './base.cssr.js' - -export default [ - { - key: 'mergedTheme', - watch: ['mergedTheme'], - CNode: baseStyle - } -] diff --git a/src/grid/styles/dark.js b/src/grid/styles/dark.js index 1e3015feb..7e1467105 100644 --- a/src/grid/styles/dark.js +++ b/src/grid/styles/dark.js @@ -1,9 +1,3 @@ -import create from '../../_styles/utils/create-component-base' - -export default create({ - theme: 'dark', - name: 'Grid', - getLocalVars (vars) { - return {} - } -}) +export default { + name: 'Grid' +} diff --git a/src/grid/styles/light.js b/src/grid/styles/light.js index a9183bc88..7e1467105 100644 --- a/src/grid/styles/light.js +++ b/src/grid/styles/light.js @@ -1,9 +1,3 @@ -import create from '../../_styles/utils/create-component-base' - -export default create({ - theme: 'light', - name: 'Grid', - getLocalVars (vars) { - return {} - } -}) +export default { + name: 'Grid' +} diff --git a/src/styles.js b/src/styles.js index 9f2396716..567c37a8a 100644 --- a/src/styles.js +++ b/src/styles.js @@ -44,7 +44,7 @@ export { baseDark, baseLight } from './_styles/base' // export { emptyDark, emptyLight } from './empty/styles' // export { formDark, formLight } from './form/styles' // export { gradientTextDark, gradientTextLight } from './gradient-text/styles' -export { gridDark, gridLight } from './grid/styles' +// export { gridDark, gridLight } from './grid/styles' export { iconDark, iconLight } from './icon/styles' export { inputDark, inputLight } from './input/styles' export { inputNumberDark, inputNumberLight } from './input-number/styles' diff --git a/src/styles.new.js b/src/styles.new.js index 40a519d01..fe11cfe7f 100644 --- a/src/styles.new.js +++ b/src/styles.new.js @@ -26,6 +26,7 @@ import { elementDark } from './element/styles' import { emptyDark } from './empty/styles' import { formDark } from './form/styles' import { gradientTextDark } from './gradient-text/styles' +import { gridDark } from './grid/styles' export const darkTheme = { common: commonDark, @@ -55,5 +56,6 @@ export const darkTheme = { Element: elementDark, Empty: emptyDark, Form: formDark, - GradientText: gradientTextDark + GradientText: gradientTextDark, + Grid: gridDark }