Skip to content

Commit

Permalink
fix: fix css variables not working on some components (didi#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
moyus authored and xxyan0205 committed Mar 8, 2019
1 parent 1a6868c commit af99607
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
4 changes: 2 additions & 2 deletions build/rollup/build-css-variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function generateVariablesStyl(variables) {
let stylContent = '/**\r\n Automatically generated when running script \'build:variables\'\r\n Do not edit or delete manually\r\n**/\r\n'

for (const variable in variables) {
if (variables.hasOwnProperty(variable)) {
if (variables.hasOwnProperty(variable) && variable !== 'support-for-ie') {
stylContent += `${variable} = var(--${variable})\n`
}
}
Expand All @@ -60,7 +60,7 @@ try {
const variablesAll = {}
files.forEach(file => {
const variablesJson = getStyleJson(file)

if (!fs.existsSync(outputLibDir)) {
fs.mkdirSync(outputLibDir)
}
Expand Down
4 changes: 2 additions & 2 deletions build/stylus-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const isSpecial = process.env.BUILD_TYPE === 'special'
module.exports = function useMixin(style) {
if (process.env.BUILD_TYPE === 'variables') {
return style
.import(path.join(__dirname, '../components/_style/mixin/theme.variable.styl'))
.import(path.join(__dirname, '../components/_style/mixin/theme.components.styl'))
.import(path.join(__dirname, '../components/_style/mixin/theme.basic.styl'))
.import(path.join(__dirname, '../components/_style/mixin/theme.variable.styl'))
.import(path.join(__dirname, '../components/_style/mixin/util.styl'))
.import(path.join(__dirname, '../node_modules/nib/lib/nib/vendor'))
.import(path.join(__dirname, '../node_modules/nib/lib/nib/gradients'))
Expand All @@ -18,4 +18,4 @@ module.exports = function useMixin(style) {
.import(path.join(__dirname, '../node_modules/nib/lib/nib/vendor'))
.import(path.join(__dirname, '../node_modules/nib/lib/nib/gradients'))
}
}
}
1 change: 0 additions & 1 deletion components/_style/mixin/theme.variable.styl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Automatically generated when running script 'build:variables'
Do not edit or delete manually
**/
support-for-ie = var(--support-for-ie)
color-primary = var(--color-primary)
color-text-base = var(--color-text-base)
color-text-base-inverse = var(--color-text-base-inverse)
Expand Down
16 changes: 12 additions & 4 deletions components/codebox/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
v-for="i in num"
:key="i"
:class="[
'md-codebox-box',
'md-codebox-box',
(i === code.length + 1) && focused && 'is-active',
code.charAt(i-1) !== '' && 'is-filled'
]"
Expand Down Expand Up @@ -264,8 +264,13 @@ export default {
font-size codebox-font-size
font-weight normal
line-height 1.2
margin-left (codebox-gutter / 2)
margin-right (codebox-gutter / 2)
if codebox-gutter is a 'unit'
margin-left (codebox-gutter / 2)
margin-right (codebox-gutter / 2)
else
margin-left "calc(%s / 2)" % codebox-gutter
margin-right "calc(%s / 2)" % codebox-gutter
border-bottom codebox-border-width solid codebox-border-color
&:first-child
margin-left 0
Expand All @@ -276,7 +281,10 @@ export default {
.md-codebox-blink
display block
height (codebox-height * 0.8)
if tab-height is a 'unit'
height (codebox-height * 0.8)
else
height "calc(%s * 0.8)" % codebox-height
width 2px
background-color codebox-blink-color
animation md-codebox-flash steps(2) 1s infinite
Expand Down
8 changes: 6 additions & 2 deletions components/tab-bar/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,12 @@ export default {
left -14px
top 50%
width 14px
margin-top 0 - tab-height * 0.4
height tab-height * 0.8
if tab-height is a 'unit'
margin-top 0 - tab-height * 0.4
height tab-height * 0.8
else
margin-top "calc(0 - %s * 0.4)" % tab-height
height "calc(%s * 0.8)" % tab-height
border-radius 50%
box-shadow: -1px 0 12px 0 rgba(0,0,0,0.2)
.md-tab-bar-end
Expand Down

0 comments on commit af99607

Please sign in to comment.