Skip to content

Commit

Permalink
feat: add variable to config HomePage width (close #2055) (#2086)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sun Haoran authored and kefranabg committed Jan 6, 2020
1 parent abc86e8 commit b72d145
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
1 change: 1 addition & 0 deletions packages/@vuepress/core/lib/client/style/config.styl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ $badgeErrorColor = #DA5961
$navbarHeight = 3.6rem
$sidebarWidth = 20rem
$contentWidth = 740px
$homePageWidth = 960px

// responsive breakpoints
$MQNarrow = 959px
Expand Down
2 changes: 1 addition & 1 deletion packages/@vuepress/theme-default/components/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default {
<style lang="stylus">
.home
padding $navbarHeight 2rem 0
max-width 960px
max-width $homePageWidth
margin 0px auto
display block
.hero
Expand Down
20 changes: 16 additions & 4 deletions packages/docs/docs/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,23 +142,35 @@ Specify which pattern of files you want to be resolved.

### palette.styl

To apply simple color overrides to the styling of the [default preset](https://github.com/vuejs/vuepress/blob/master/packages/@vuepress/core/lib/client/style/config.styl) or define some color variables for using later, you can create a `.vuepress/styles/palette.styl` file.
To apply simple overrides to the styling of the [default preset](https://github.com/vuejs/vuepress/blob/master/packages/@vuepress/core/lib/client/style/config.styl) or define some variables to use later, you can create a `.vuepress/styles/palette.styl` file.

There are some color variables you can tweak:
There are some predefined variables you can tweak:

``` stylus
// showing default values
// colors
$accentColor = #3eaf7c
$textColor = #2c3e50
$borderColor = #eaecef
$codeBgColor = #282c34
$arrowBgColor = #ccc
$badgeTipColor = #42b983
$badgeWarningColor = darken(#ffe564, 35%)
$badgeErrorColor = #DA5961
// layout
$navbarHeight = 3.6rem
$sidebarWidth = 20rem
$contentWidth = 740px
$homePageWidth = 960px
// responsive breakpoints
$MQNarrow = 959px
$MQMobile = 719px
$MQMobileNarrow = 419px
```

::: danger Note
You should ONLY write color variables in this file. Since `palette.styl` will be imported at the end of the root Stylus config file, as a config, several files will use it, so once you wrote styles here, your style would be duplicated by multiple times.
You should ONLY define variables in this file. Since `palette.styl` will be imported at the end of the root Stylus config file, as a config, several files will use it, so once you wrote styles here, your style would be duplicated by multiple times.
:::

### index.styl
Expand Down
20 changes: 16 additions & 4 deletions packages/docs/docs/zh/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,23 +138,35 @@ Specify which pattern of files you want to be resolved.

### palette.styl

如果要对[默认预设](https://github.com/vuejs/vuepress/blob/master/packages/@vuepress/core/lib/client/style/config.styl)的样式应用简单的颜色替换,或者定义一些颜色变量供以后使用,你可以创建一个 `.vuepress/styles/palette.styl` 文件。
如果要对[默认预设](https://github.com/vuejs/vuepress/blob/master/packages/@vuepress/core/lib/client/style/config.styl)的样式进行简单的替换,或者定义一些变量供以后使用,你可以创建一个 `.vuepress/styles/palette.styl` 文件。

你可以调整一些颜色变量:
你可以调整的一些变量如下:

``` stylus
// 默认值
// 颜色
$accentColor = #3eaf7c
$textColor = #2c3e50
$borderColor = #eaecef
$codeBgColor = #282c34
$arrowBgColor = #ccc
$badgeTipColor = #42b983
$badgeWarningColor = darken(#ffe564, 35%)
$badgeErrorColor = #DA5961
// 布局
$navbarHeight = 3.6rem
$sidebarWidth = 20rem
$contentWidth = 740px
$homePageWidth = 960px
// 响应式变化点
$MQNarrow = 959px
$MQMobile = 719px
$MQMobileNarrow = 419px
```

::: danger Note
你应该**只在**这个文件中写入颜色变量。因为 `palette.styl` 将在根的 stylus 配置文件的末尾引入,作为配置,它将被多个文件使用,所以一旦你在这里写了样式,你的样式就会被多次复制。
你应该**只在**这个文件中定义变量。因为 `palette.styl` 将在根的 stylus 配置文件的末尾引入,作为配置,它将被多个文件使用,所以一旦你在这里写了样式,你的样式就会被多次复制。
:::

### index.styl
Expand Down

0 comments on commit b72d145

Please sign in to comment.