Skip to content

Commit b72d145

Browse files
Sun Haorankefranabg
Sun Haoran
authored andcommitted
feat: add variable to config HomePage width (close #2055) (#2086)
1 parent abc86e8 commit b72d145

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed

packages/@vuepress/core/lib/client/style/config.styl

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ $badgeErrorColor = #DA5961
1212
$navbarHeight = 3.6rem
1313
$sidebarWidth = 20rem
1414
$contentWidth = 740px
15+
$homePageWidth = 960px
1516

1617
// responsive breakpoints
1718
$MQNarrow = 959px

packages/@vuepress/theme-default/components/Home.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export default {
8686
<style lang="stylus">
8787
.home
8888
padding $navbarHeight 2rem 0
89-
max-width 960px
89+
max-width $homePageWidth
9090
margin 0px auto
9191
display block
9292
.hero

packages/docs/docs/config/README.md

+16-4
Original file line numberDiff line numberDiff line change
@@ -142,23 +142,35 @@ Specify which pattern of files you want to be resolved.
142142

143143
### palette.styl
144144

145-
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.
145+
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.
146146

147-
There are some color variables you can tweak:
147+
There are some predefined variables you can tweak:
148148

149149
``` stylus
150-
// showing default values
150+
// colors
151151
$accentColor = #3eaf7c
152152
$textColor = #2c3e50
153153
$borderColor = #eaecef
154154
$codeBgColor = #282c34
155+
$arrowBgColor = #ccc
155156
$badgeTipColor = #42b983
156157
$badgeWarningColor = darken(#ffe564, 35%)
157158
$badgeErrorColor = #DA5961
159+
160+
// layout
161+
$navbarHeight = 3.6rem
162+
$sidebarWidth = 20rem
163+
$contentWidth = 740px
164+
$homePageWidth = 960px
165+
166+
// responsive breakpoints
167+
$MQNarrow = 959px
168+
$MQMobile = 719px
169+
$MQMobileNarrow = 419px
158170
```
159171

160172
::: danger Note
161-
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.
173+
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.
162174
:::
163175

164176
### index.styl

packages/docs/docs/zh/config/README.md

+16-4
Original file line numberDiff line numberDiff line change
@@ -138,23 +138,35 @@ Specify which pattern of files you want to be resolved.
138138

139139
### palette.styl
140140

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

143-
你可以调整一些颜色变量:
143+
你可以调整的一些变量如下:
144144

145145
``` stylus
146-
// 默认值
146+
// 颜色
147147
$accentColor = #3eaf7c
148148
$textColor = #2c3e50
149149
$borderColor = #eaecef
150150
$codeBgColor = #282c34
151+
$arrowBgColor = #ccc
151152
$badgeTipColor = #42b983
152153
$badgeWarningColor = darken(#ffe564, 35%)
153154
$badgeErrorColor = #DA5961
155+
156+
// 布局
157+
$navbarHeight = 3.6rem
158+
$sidebarWidth = 20rem
159+
$contentWidth = 740px
160+
$homePageWidth = 960px
161+
162+
// 响应式变化点
163+
$MQNarrow = 959px
164+
$MQMobile = 719px
165+
$MQMobileNarrow = 419px
154166
```
155167

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

160172
### index.styl

0 commit comments

Comments
 (0)