Skip to content

Commit 39a14fa

Browse files
fksidharthachatterjee
authored andcommitted
feat(www): Spring cleaning episode 5 (#12603)
* feat(www): Spring cleaning episode 5 Attention, noooooooooob Friday stuff … potential public humiliation stuff 😅🥳 Since we want to define `presets.space` in relation to Typography.js’ `rhythm`, but doing so directly in `presets` would have introduced a circular dependency among `utils/presets` and `utils/typography` (from what _I_ think I understand 🤓), up to now we had to put values from `presets.space` through `rhythm` for each usage in components: ``` import { space } from "../../utils/presets" import { rhythm } from "../../utils/typography" padding: ${rhythm(space[7])} ${rhythm(space[4])} ${rhythm(space[4])}; ``` This caused a lot of unnecessary noise, and was an ugly derivation from the norm for that one group of design tokens in `presets` … and of course smells a lot. This PR cleans that up — as good as I can. I would appreciate any input and I’m happy to adjust this, crossing fingers that this PR at least shows where I want things to go: ``` import { space } from "../../utils/presets" padding: ${space[7]} ${space[4]} ${space[4]}; ``` - minimize direct usage of Typography.js’ `scale` and `rhythm` - maximize usage of `presets` tokens for consistency, and make that easy and as concise as possible — - split up design tokens in `utils/presets` and move them to `utils/tokens/*` — theme-style FTW?! - move `utils/colors` to `utils/tokens/colors` - refactor to remove circular dependency among `utils/typography` and `utils.presets` — this enables us to use Typography.js’ `rhythm` in `utils.presets` so we can avoid manual „composition“ of `scale` values in components - move `paddingLeft` helper function used in `components/sidebar/accordion` and `components/sidebar/section-title` to `utils/sidebar/indention` * Tidy stuff from #12087 * Tidy * D’oh * Use `presets.fonts` in components … instead of `typography.options` and `join(`,`) Move font stack definitions to tokens. * Drop uppercase and tracking for main nav items Lowercase is (subjectively) more legible and friendly, takes less space, matches the mobile navigation items, and magically resolves space issues on screens below „lg“ * Fix refactoring fails * Drop WebKit scrollbars for starters, showcase * Drop WebKit scrollbar styles for docs/tutorials, plugins sidebars * Realign docs/tutorial, plugins sidebars - move padding to anchor/title — allow - calmer „Expand/Collapse All“ button - increase sidebar „utility“ height (containing the „Expand/Collapse All“ button) height/whitespace - move a couple sidebar variables to `utils/sidebars/presets`, enables configuration of a couple of things: - sidebar item hover background color - sidebar item borders — I decided to drop those for now, can be brought back via changing a color variable - minimum item height - active „section item“ background - sidebar background color for offscreen/small screens, and persistent/larger screens - adjust `colors.ui` - drop `colors.ui.border` - freshen up `light`, `bright`, and `whisper` - bump default sidebar width - simplify „stepsUI“ (used for anchor links in „Tutorial“) — remove dashed lines - reduce sidebar active item font weight — dial it back to 600, which should be supported by the majority of the system font stack - improved distinction among top-level sections (via border-bottom and vertical whitespace) - sidebar expand/collapse chevron button now covers 100% of the item's height * Fix padding-right for subitems with caret * Move `level` info to `item-list`, hide level 0 expanded accordion border bottom if there’s only one accordion * Remove unused * Fix apostrophes
1 parent dc4afa1 commit 39a14fa

File tree

106 files changed

+1194
-1065
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+1194
-1065
lines changed

www/src/components/api-reference/doc-block.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import {
1212
} from "./signature"
1313
import ReturnBlock from "./returns"
1414
import { Header } from "./utils"
15-
import { options, scale } from "../../utils/typography"
15+
import { scale } from "../../utils/typography"
16+
import { fonts } from "../../utils/presets"
1617

1718
const Optional = styled.span`
1819
:before {
@@ -30,7 +31,7 @@ const Deprecated = ({ definition }) => {
3031
p:before {
3132
color: #e8bd36;
3233
content: "(deprecated) ";
33-
font-family: ${options.headerFontFamily.join(`,`)};
34+
font-family: ${fonts.header};
3435
}
3536
`}
3637
dangerouslySetInnerHTML={{

www/src/components/api-reference/examples.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react"
22
import { graphql } from "gatsby"
33

4-
import { rhythm } from "../../utils/typography"
4+
import { space } from "../../utils/presets"
55

66
const Example = ({ example }) => (
77
<div className="gatsby-highlight">
@@ -20,7 +20,7 @@ const ExamplesBlock = ({ definition }) => {
2020
if (definition.examples && definition.examples.length > 0) {
2121
return (
2222
<div>
23-
<h4 css={{ marginTop: rhythm(1) }}>Example</h4>
23+
<h4 css={{ marginTop: space[6] }}>Example</h4>
2424
{` `}
2525
{definition.examples.map((example, i) => (
2626
<Example example={example} key={`example ${i}`} />

www/src/components/api-reference/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { graphql } from "gatsby"
33

44
import DocBlock from "./doc-block"
55

6-
import { rhythm } from "../../utils/typography"
6+
import { space } from "../../utils/presets"
77

88
export default ({
99
docs,
@@ -15,7 +15,7 @@ export default ({
1515
<div
1616
id={definition.name}
1717
key={`reference list ${definition.name}`}
18-
css={{ marginBottom: rhythm(1) }}
18+
css={{ marginBottom: space[6] }}
1919
>
2020
{i !== 0 && <hr />}
2121
<DocBlock

www/src/components/api-reference/params.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import { css } from "@emotion/core"
44

55
import DocBlock from "./doc-block"
66
import { SubHeader } from "./utils"
7-
import { rhythm } from "../../utils/typography"
7+
import { space } from "../../utils/presets"
88

99
const List = ({ elements, level, ignoreParams }) => (
1010
<ul
1111
css={css`
1212
list-style-type: none;
13-
margin-top: ${rhythm(0.5)};
14-
margin-left: ${rhythm(0.75)};
13+
margin-top: ${space[3]};
14+
margin-left: ${space[4]};
1515
margin-bottom: 0;
1616
`}
1717
>

www/src/components/api-reference/returns.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { graphql } from "gatsby"
33

44
import DocBlock from "./doc-block"
55
import { SubHeader } from "./utils"
6-
// import { rhythm } from "../../utils/typography"
76

87
const ReturnBlock = ({ definition, level }) => {
98
if (definition.returns && definition.returns.length > 0) {

www/src/components/api-reference/signature.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import { css } from "@emotion/core"
55
import { graphql } from "gatsby"
66

77
import { SubHeader } from "./utils"
8-
import { options, rhythm } from "../../utils/typography"
8+
import { space, fonts } from "../../utils/presets"
99

1010
const Wrapper = styled(`span`)`
11-
font-family: ${options.headerFontFamily.join(`,`)};
11+
font-family: ${fonts.header};
1212
font-weight: 400;
1313
1414
:before,
@@ -27,7 +27,7 @@ const Wrapper = styled(`span`)`
2727
props.block &&
2828
css`
2929
display: block;
30-
margin-top: ${rhythm(0.35)};
30+
margin-top: ${space[2]};
3131
`};
3232
`
3333

www/src/components/api-reference/utils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react"
22
import { css } from "@emotion/core"
33

4-
import { rhythm } from "../../utils/typography"
4+
import { space } from "../../utils/presets"
55

66
export const Header = ({ children, level }) => {
77
const Tag = `h${Math.min(3 + level * 2, 6)}`
@@ -12,7 +12,7 @@ export const Header = ({ children, level }) => {
1212
margin: 0,
1313
...(level > 0
1414
? {
15-
marginTop: rhythm(0.35),
15+
marginTop: space[2],
1616
}
1717
: {}),
1818
}}
@@ -28,7 +28,7 @@ export const SubHeader = ({ children, level }) => {
2828
<Tag
2929
css={css`
3030
margin: 0;
31-
margin-top: ${rhythm(0.35)};
31+
margin-top: ${space[2]};
3232
`}
3333
>
3434
{children}

www/src/components/avatar.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from "react"
22
import Img from "gatsby-image"
33

4-
import { rhythm } from "../utils/typography"
54
import { space, radii } from "../utils/presets"
65

76
const Avatar = ({ image, alt }) => (
@@ -12,7 +11,7 @@ const Avatar = ({ image, alt }) => (
1211
borderRadius: radii[6],
1312
display: `inline-block`,
1413
// todo remove
15-
marginRight: rhythm(space[3]),
14+
marginRight: space[3],
1615
marginBottom: 0,
1716
verticalAlign: `top`,
1817
// prevents image twitch in Chrome when hovering the card

www/src/components/banner.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ import React from "react"
22
import styled from "@emotion/styled"
33
import { OutboundLink } from "gatsby-plugin-google-analytics"
44

5-
import { colors, space, dimensions } from "../utils/presets"
6-
import { rhythm, options } from "../utils/typography"
5+
import { colors, space, dimensions, fonts } from "../utils/presets"
76

8-
const horizontalPadding = rhythm(space[6])
7+
const horizontalPadding = space[6]
98
const backgroundColor = colors.gatsby
109

1110
const BannerContainer = styled(`div`)`
@@ -28,7 +27,7 @@ const InnerContainer = styled(`div`)`
2827

2928
const Content = styled(`div`)`
3029
color: ${colors.ui.bright};
31-
font-family: ${options.headerFontFamily.join(`,`)};
30+
font-family: ${fonts.header};
3231
padding-left: ${horizontalPadding};
3332
padding-right: ${horizontalPadding};
3433
-webkit-font-smoothing: antialiased;

www/src/components/blog-post-preview-item.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import React from "react"
22
import { Link, graphql } from "gatsby"
33

44
import Avatar from "./avatar"
5-
import { options } from "../utils/typography"
6-
import { colors } from "../utils/presets"
5+
import { colors, fonts } from "../utils/presets"
76

87
const formatDate = dateString =>
98
new Date(dateString).toLocaleDateString(`en-EN`, {
@@ -42,7 +41,7 @@ const BlogPostPreviewItem = ({ post, className }) => (
4241
<div
4342
css={{
4443
display: `inline-block`,
45-
fontFamily: options.headerFontFamily.join(`,`),
44+
fontFamily: fonts.header,
4645
color: colors.gray.calm,
4746
}}
4847
>

0 commit comments

Comments
 (0)