Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate styled-system #1679

Merged
merged 58 commits into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
a0ffca9
refactor: remove Fixed component
Kikobeats Dec 31, 2023
b034218
refactor: initial migration
Kikobeats Dec 31, 2023
7d0d355
refactor: migrate header
Kikobeats Feb 8, 2024
6f246e0
refactor: migrate footer
Kikobeats Mar 3, 2024
7692d37
refactor: rename themeCss into theme
Kikobeats Mar 6, 2024
b886bed
refactor: migrate buttons
Kikobeats Mar 9, 2024
5753c12
refactor: migrate storybook components
Kikobeats Mar 12, 2024
da894a3
fix: footer attributes (#1709)
breadadams May 12, 2024
f9f243d
migrate styled-system (components & product pages) (#1712)
breadadams May 15, 2024
939b1e1
migrate styled-system (company pages) (#1713)
breadadams May 15, 2024
abcf0d7
migrate styled-system (developers pages) (#1714)
breadadams May 15, 2024
bd39d4c
migrate styled-system (other pages) (#1715)
breadadams May 15, 2024
59d28e7
fix: linter
Kikobeats May 16, 2024
f7783bd
refactor: remove comment
Kikobeats May 16, 2024
9fde080
Merge branch 'master' into styled-components
Kikobeats May 16, 2024
c46a173
fix: detect language from title
Kikobeats May 16, 2024
292166c
fix: highlight lines
Kikobeats May 17, 2024
3a6b4dd
fix: tabs non selected style
Kikobeats May 17, 2024
5694197
fix: get language from props
Kikobeats May 17, 2024
c9d089f
fix: json highlight syntax
Kikobeats May 18, 2024
6a4d273
refactor: avoid defaultProps
Kikobeats May 18, 2024
d782453
refactor: avoid defaultProps for styled-components
Kikobeats May 18, 2024
2492390
refactor: remove `defaultProps` (#1717)
breadadams May 22, 2024
f488695
fix: passing theme property
Kikobeats May 31, 2024
b783037
refactor(/formats): add DotsBackground
Kikobeats May 31, 2024
ee062e6
refactor: add announcement on logo page
Kikobeats May 31, 2024
f697685
chore: add tooltip type
Kikobeats Jun 1, 2024
ceb60a5
refactor: avoid capitalize
Kikobeats Jun 1, 2024
6347a33
refactor(/user-agents): better experience
Kikobeats Jun 1, 2024
24c5034
fix: linter
Kikobeats Jun 1, 2024
c3bb46e
refactor: theme prop into isDark
Kikobeats Jun 1, 2024
63eb9ea
fix: setup body background under dark
Kikobeats Jun 1, 2024
732cdac
fix: letter spacing
Kikobeats Jun 2, 2024
d044a0c
fix: linter
Kikobeats Jun 2, 2024
41824a7
refactor: adjust aspect ratio
Kikobeats Jun 2, 2024
252139b
fix: sdk page
Kikobeats Jun 2, 2024
5e641cb
fix: user-agents title
Kikobeats Jul 16, 2024
b35cc4f
chore: migrate screenshot
Kikobeats Jul 16, 2024
a5cfcd1
build: update dependencies
Kikobeats Jul 16, 2024
07b8089
fix: user-agent script
Kikobeats Jul 16, 2024
a42945c
fix: linter
Kikobeats Jul 17, 2024
a8443bb
build: update dependencies
Kikobeats Jul 18, 2024
18bd026
build: update dependencies
Kikobeats Jul 18, 2024
d2f5f3e
fix: warning
Kikobeats Jul 18, 2024
de7bd52
refactor: don't pass down unnecessary props
Kikobeats Jul 19, 2024
9434ade
fix: as → forwardedAs
Kikobeats Jul 19, 2024
8f1def2
fix: button spacing
Kikobeats Jul 20, 2024
e94c4fe
fix: blog titles
Kikobeats Jul 20, 2024
4b53b6a
refactor: adjust spaces
Kikobeats Jul 20, 2024
ab16b3f
fix: card size
Kikobeats Jul 20, 2024
d2f62c9
fix: css syntax
Kikobeats Jul 20, 2024
d2834dc
refactor: adjust max-width
Kikobeats Jul 20, 2024
1c24b9e
chore(storybook): disable telemetry
Kikobeats Jul 20, 2024
0426e34
chore: remove MQLEditor component
Kikobeats Jul 20, 2024
3351778
fix: linter
Kikobeats Jul 20, 2024
7e1a1d7
fix: react warnings
Kikobeats Jul 20, 2024
c9d8e67
fix(markdown): iframe max-width
Kikobeats Jul 20, 2024
66c41d1
fix: linter
Kikobeats Jul 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ module.exports = {
// use babel-plugin-remove-graphql-queries to remove static queries from components when rendering in storybook
require.resolve('babel-plugin-remove-graphql-queries'),
// use babel-plugin-react-docgen to ensure PropTables still appear
require.resolve('babel-plugin-react-docgen')
require.resolve('babel-plugin-react-docgen'),
require.resolve('babel-plugin-styled-components')
]
}
}
Expand Down
17 changes: 9 additions & 8 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { ThemeProvider } from 'styled-components'
import { LocationProvider } from '@gatsbyjs/reach-router'

import { ThemeProvider } from 'styled-components'
import Flex from 'components/elements/Flex'
import themeSpec, { theme } from 'theme'
import React from 'react'
import theme from 'theme'

import '@storybook/addon-console'

Expand All @@ -24,13 +23,15 @@ window.___navigate = pathname => {

export const decorators = [
Story => (
<ThemeProvider theme={theme}>
<ThemeProvider theme={themeSpec}>
<LocationProvider>
<Flex
p={3}
justiContent='center'
alignItems='baseline'
flexDirection='column'
css={theme({
p: 3,
justifyContent: 'center',
alignItems: 'baseline',
flexDirection: 'column'
})}
>
<Story />
</Flex>
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@
"@stripe/react-stripe-js": "~2.4.0",
"@stripe/stripe-js": "~2.2.2",
"@styled-system/prop-types": "~5.1.5",
"@techstack/styled-system": "~1.0.341",
"@tippyjs/react": "~4.2.6",
"@vercel/analytics": "~1.2.2",
"babel-plugin-styled-components": "~2.1.4",
"beauty-error": "~1.2.18",
"cssnano": "~6.0.2",
"cssnano-preset-advanced": "~6.0.2",
Expand All @@ -135,7 +137,6 @@
"mdx-scoped-runtime": "~0.8.0",
"microsoft-capitalize": "~1.0.5",
"normalize.css": "~8.0.1",
"palx": "~1.0.3",
"path-browserify": "~1.0.1",
"polished": "~4.3.1",
"postcss": "~8.4.32",
Expand All @@ -152,7 +153,7 @@
"react-twitter-widgets": "~1.11.0",
"remark-slug": "~7.0.1",
"sass": "~1.70.0",
"styled-components": "5",
"styled-components": "~6.1.6",
"styled-is": "~1.3.0",
"styled-system": "~5.1.5",
"swr": "~2.2.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const SliderContainerWrapper = styled('div')`
animation-direction: ${props => props.animationDirection};
`

const SliderContainerChildren = styled.div`
const SliderContainerChildren = styled('div')`
display: inline-block;
`

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import React from 'react'
import { Story } from 'story'
import { Microlink } from 'components/logos'
import { storiesOf } from '@storybook/react'
import { theme, transition } from 'theme'
import styled from 'styled-components'
import range from 'lodash/range'
import { Story } from 'story'
import React from 'react'

import {
Flex,
Box,
BackgroundSlider,
BackgroundSliderContainer
} from 'components/elements'
import { transition } from 'theme'
import range from 'lodash/range'
import { Microlink } from 'components/logos'

const NoWrap = styled(Flex)`
white-space: nowrap;
Expand All @@ -29,13 +30,9 @@ const LogoWrap = styled(Box)`
&:hover {
opacity: 0.8;
}
${theme({ px: 4, display: 'inline-block' })}
`

LogoWrap.defaultProps = {
display: 'inline-block',
px: 4
}

const code = `
import {
BackgroundSliderContainer,
Expand All @@ -58,7 +55,7 @@ export default () => (

storiesOf('Elements', module).add('BackgroundSlider', () => (
<Story name='BackgroundSlider' code={code}>
<BackgroundSliderContainer py={0} px={0} maxWidth='100%'>
<BackgroundSliderContainer css={theme({ py: 0, px: 0, maxWidth: '100%' })}>
<BackgroundSlider duration={80} animationDirection='reverse'>
{range(30).map(index => (
<LogoWrap key={index}>
Expand Down
23 changes: 14 additions & 9 deletions src/components/elements/Badge/Badge.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
import styled from 'styled-components'
import { theme } from 'theme'

import Text from '../Text'

const Badge = styled(Text)`
padding: 2px 12px;
text-transform: uppercase;
position: relative;
vertical-align: middle;

${theme({
letterSpacing: 2,
border: '0.5px solid',
fontSize: '12px',
fontWeight: 'bold',
bg: 'secondary',
borderRadius: 5,
fontFamily: 'sans',
color: 'white'
})}
`

Badge.defaultProps = {
letterSpacing: 2,
border: '0.5px solid',
as: 'span',
fontSize: '12px',
fontWeight: 'bold',
bg: 'secondary',
borderRadius: 5,
fontFamily: 'sans',
color: 'white'
as: 'span'
}

export default Badge
60 changes: 7 additions & 53 deletions src/components/elements/Box.js
Original file line number Diff line number Diff line change
@@ -1,63 +1,17 @@
import {
compose,
space,
border,
color,
borders,
lineHeight,
width,
flex,
order,
alignSelf,
compose,
layout,
position,
fontSize,
variant,
textAlign,
maxWidth,
boxShadow,
display,
height
} from 'styled-system'
space,
variant
} from '@techstack/styled-system'

import styled from 'styled-components'
import propTypes from '@styled-system/prop-types'

const Box = styled('div')(
compose(
space,
textAlign,
maxWidth,
boxShadow,
display,
borders,
lineHeight,
height,
width,
fontSize,
color,
flex,
order,
alignSelf,
position,
variant({ key: 'boxStyles' })
)
compose(border, color, layout, position, space, variant({ key: 'button' }))
)

Box.propTypes = {
...propTypes.space,
...propTypes.textAlign,
...propTypes.maxWidth,
...propTypes.boxShadow,
...propTypes.border,
...propTypes.display,
...propTypes.width,
...propTypes.height,
...propTypes.fontSize,
...propTypes.color,
...propTypes.flex,
...propTypes.order,
...propTypes.alignSelf,
...propTypes.position,
...propTypes.lineHeight
}

export default Box
97 changes: 69 additions & 28 deletions src/components/elements/Button/Button.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,78 @@
import styled, { css } from 'styled-components'
import { createCssState } from 'helpers/style'
import { colors } from 'theme'
import { transition, theme as themeProp, colors, space, gradient } from 'theme'
import styled from 'styled-components'
import Box from '../Box'

import ButtonBase from './ButtonBase'
const getVariant = ({ theme, variant }) => {
const { background = 'link', color = 'white' } =
theme.variants.buttons[variant] || {}
return { background, color }
}

export const hoverStyle = createCssState({
selector: '&:hover:not([disabled])',
state: 'hover',
css: css`
background-color: ${({ color }) => colors[color]};
color: ${({ bg }) => colors[bg]};
box-shadow: 0 0 0 1px ${({ bg }) => colors[bg]};
`
})
export const hoverStyle = ({ theme, variant }) => {
const { background, color } = getVariant({ theme, variant })
return {
cursor: 'pointer',
background: color,
color: background,
boxShadow: `0 0 0 1px ${colors[background]}`
}
}

export const disabledStyle = createCssState({
selector: '&:disabled',
state: 'disabled',
css: css`
const Button = styled(Box)`
transition: background-color ${transition.medium}, color ${transition.medium},
box-shadow ${transition.medium};
appearance: none;
display: inline-block;
text-align: center;
text-decoration: none;
vertical-align: middle;
white-space: nowrap;
outline: 0;

${({ variant }) =>
variant === 'gradient' &&
`
&&& {
opacity: 0.8;
cursor: not-allowed;
background-color: ${colors.black05};
color: ${colors.black50};
cursor: not-allowed;
box-shadow: 0 0 0 1px ${colors.black20};
.path {
stroke: ${colors.black30};
transition: filter ${transition.medium};
background: ${gradient};
padding: ${space[1]};
&:hover {
box-shadow: none;
filter: hue-rotate(40deg);
}
}
`
})
`}

${({ theme, variant }) => {
const { background, color } = getVariant({ theme, variant })
return themeProp({
fontFamily: 'sans',
fontSize: 1,
fontWeight: 'bold',
px: 3,
py: 2,
border: 0,
borderRadius: 2,
background,
color,
boxShadow: variant === 'white' ? `0 0 0 1px ${color}` : undefined,
_hover: hoverStyle({ theme, variant }),
_disabled: {
opacity: 0.8,
cursor: 'not-allowed',
background: colors.black05,
color: colors.black50,
boxShadow: `0 0 0 1px ${colors.black20}`,
'.path': {
stroke: colors.black30
}
}
})
}}
`

const Button = styled(ButtonBase)(hoverStyle, disabledStyle)
Button.defaultProps = {
as: 'button'
}

export default Button
44 changes: 0 additions & 44 deletions src/components/elements/Button/ButtonBase.js

This file was deleted.

Loading
Loading