Skip to content

Commit

Permalink
Merge branch 'main' into disabled-text
Browse files Browse the repository at this point in the history
  • Loading branch information
simurai authored Oct 20, 2021
2 parents 0dff2a1 + f013be6 commit 31f072e
Show file tree
Hide file tree
Showing 14 changed files with 6,572 additions and 3,656 deletions.
5 changes: 5 additions & 0 deletions .changeset/curly-pans-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/css": patch
---

Fixing broken close span tag in the docs.
11 changes: 11 additions & 0 deletions docs/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: [
'@storybook/addon-a11y',
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/preset-scss',
'@whitespace/storybook-addon-html',
'storybook-addon-designs'
]
}
15 changes: 15 additions & 0 deletions docs/.storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<style>
.story-wrap {
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans,
Helvetica Neue, sans-serif;
color: var(--color-fg-default);
background-color: var(--color-canvas-default);
padding: 1rem;
}

.theme-wrap {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
height: 100vh;
}
</style>
120 changes: 120 additions & 0 deletions docs/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import '../../src/docs.scss'
import '../../src/index.scss'
import '../../src/base/index.scss'

export const parameters = {
actions: {argTypesRegex: '^on[A-Z].*'},
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/
},
expanded: true
},

layout: 'fullscreen',
html: {
root: '#story' // target id for html tab (should be direct parent of <Story /> for easy copy/paste)
}
}

export const globalTypes = {
theme: {
name: 'Theme',
description: 'Switch themes',
defaultValue: 'light',
toolbar: {
icon: 'circlehollow',
items: ['light', 'light_protanopia', 'dark', 'dark_dimmed', 'dark_high_contrast', 'dark_protanopia', 'all'],
showName: true
}
}
}

export const decorators = [
(Story, context) => {
if (context.globals.theme === 'all') {
return (
<div class="theme-wrap">
<div data-color-mode="light" data-light-theme="light" className="story-wrap" id="story">
<Story {...context} />
</div>

<div data-color-mode="light" data-light-theme="light_protanopia" className="story-wrap" id="story">
<Story {...context} />
</div>

<div data-color-mode="dark" data-dark-theme="dark" className="story-wrap" id="story">
<Story {...context} />
</div>

<div data-color-mode="dark" data-dark-theme="dark_dimmed" className="story-wrap" id="story">
<Story {...context} />
</div>

<div data-color-mode="dark" data-dark-theme="dark_high_contrast" className="story-wrap" id="story">
<Story {...context} />
</div>

<div data-color-mode="dark" data-dark-theme="dark_protanopia" className="story-wrap" id="story">
<Story {...context} />
</div>
</div>
)
}

if (context.globals.theme === 'light') {
return (
<div data-color-mode="light" data-light-theme="light" className="story-wrap" id="story">
<Story {...context} />
</div>
)
}

if (context.globals.theme === 'light_protanopia') {
return (
<div data-color-mode="light" data-light-theme="light_protanopia" className="story-wrap" id="story">
<Story {...context} />
</div>
)
}

if (context.globals.theme === 'dark') {
return (
<div data-color-mode="dark" data-dark-theme="dark" className="story-wrap" id="story">
<Story {...context} />
</div>
)
}

if (context.globals.theme === 'dark_dimmed') {
return (
<div data-color-mode="dark" data-dark-theme="dark_dimmed" className="story-wrap" id="story">
<Story {...context} />
</div>
)
}

if (context.globals.theme === 'dark_high_contrast') {
return (
<div data-color-mode="dark" data-dark-theme="dark_high_contrast" className="story-wrap" id="story">
<Story {...context} />
</div>
)
}

if (context.globals.theme === 'dark_protanopia') {
return (
<div data-color-mode="dark" data-dark-theme="dark_protanopia" className="story-wrap" id="story">
<Story {...context} />
</div>
)
}

return (
<div className="story-wrap" id="story">
<Story {...context} />
</div>
)
}
]
2 changes: 1 addition & 1 deletion docs/content/components/forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ All our inputs and buttons side-by-side for easy testing of sizing and alignment
<button class="btn" type="button">Button</button>
<button class="btn" type="button" aria-expanded="false" aria-haspopup="true">
Select menu
<span class="dropdown-caret">
<span class="dropdown-caret"></span>
</button>
<input class="form-control" type="text" placeholder="Standard input" aria-label="Repository description" />
<input class="form-control input-monospace" type="text" placeholder="Monospace input" aria-label="SHA" />
Expand Down
28 changes: 22 additions & 6 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,23 @@
"clean": "gatsby clean",
"develop": "ln -sf ../dist . && gatsby develop -H 0.0.0.0",
"build-content": "gatsby build --prefix-paths",
"build": "./script/now-build.sh"
"build": "./script/now-build.sh",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
},
"dependencies": {
"@babel/preset-react": "^7.10.4",
"@koddsson/postcss-sass": "5.0.0",
"@primer/components": "^17.1.0",
"@primer/gatsby-theme-doctocat": "^1.7.0",
"@primer/octicons": "^11.0.0",
"@primer/octicons-react": "^11.0.0",
"@primer/components": "30.3.0",
"@primer/gatsby-theme-doctocat": "2.0.0",
"@primer/octicons": "16.0.0",
"@primer/octicons-react": "16.0.0",
"@primer/primitives": "4.2.0",
"@svgr/webpack": "5.5.0",
"autoprefixer": "10.3.7",
"babel-preset-gatsby": "^1.14.0",
"chroma-js": "^2.1.2",
"clsx": "^1.1.1",
"core-js": "^3.18.2",
"gatsby": "2.32.13",
"gatsby-plugin-alias-imports": "^1.0.5",
Expand All @@ -29,7 +32,7 @@
"postcss": "8.3.9",
"postcss-import": "14.0.2",
"postcss-load-config": "3.1.0",
"postcss-loader": "4.2.0",
"postcss-loader": "4.3.0",
"postcss-scss": "4.0.1",
"postcss-simple-vars": "6.0.3",
"prop-types": "^15.7.2",
Expand All @@ -43,5 +46,18 @@
},
"engines": {
"node": ">= 10.x"
},
"devDependencies": {
"@babel/core": "^7.15.8",
"@storybook/addon-a11y": "6.3.10",
"@storybook/addon-actions": "^6.3.12",
"@storybook/addon-essentials": "^6.3.12",
"@storybook/addon-links": "^6.3.12",
"@storybook/addon-postcss": "2.0.0",
"@storybook/preset-scss": "^1.0.3",
"@storybook/react": "6.3.12",
"@whitespace/storybook-addon-html": "^5.0.0",
"babel-loader": "^8.2.2",
"storybook-addon-designs": "6.2.0"
}
}
26 changes: 14 additions & 12 deletions docs/src/@primer/gatsby-theme-doctocat/components/hero.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import {Box, Heading, Text} from '@primer/components'
import {Box, Heading, Text, ThemeProvider} from '@primer/components'
import {Container} from '@primer/gatsby-theme-doctocat'
import React from 'react'
import {version} from '../../../../../package.json'
import {ReactComponent as HeroIllustration} from '../../../hero-illustration.svg'

function Hero() {
return (
<Box bg="black" py={6}>
<Container>
<Heading color="blue.4" fontSize={7} m={0}>
Primer CSS
</Heading>
<Text as="p" fontFamily="mono" mt={0} mb={2} color="blue.3" fontSize={2}>
v{version}
</Text>
<HeroIllustration />
</Container>
</Box>
<ThemeProvider colorMode="night" nightScheme="dark_dimmed">
<Box bg="canvas.default" py={6}>
<Container>
<Heading color="accent.fg" fontSize={7} m={0}>
Primer CSS
</Heading>
<Text as="p" fontFamily="mono" mt={0} mb={2} color="fg.default" fontSize={2}>
v{version}
</Text>
<HeroIllustration />
</Container>
</Box>
</ThemeProvider>
)
}

Expand Down
20 changes: 10 additions & 10 deletions docs/src/hero-illustration.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions docs/src/stories/Button.stories.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React from 'react'
import clsx from 'clsx'

export default {
title: 'Components/Button',
parameters: {
design: {
type: 'figma',
url: 'https://www.figma.com/file/GCvY3Qv8czRgZgvl1dG6lp/Primer-Web?node-id=4371%3A7128'
}
},
argTypes: {
variant: {
options: [0, 1, 2, 3], // iterator
mapping: [null, 'btn-primary', 'btn-outline', 'btn-danger'], // values
control: {
type: 'select',
labels: ['default', 'primary', 'outline', 'danger']
},
defaultValue: ''
},
label: {
defaultValue: 'Button',
type: 'string',
name: 'label',
description: 'string'
}
}
}

const Template = ({label, variant}) => (
<>
<button className={clsx('btn', variant && `${variant}`)}>{label}</button>
</>
)

export const Button = Template.bind({})
17 changes: 17 additions & 0 deletions docs/src/stories/GettingStarted.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {Meta} from '@storybook/addon-docs'

<Meta title="Getting Started" />

# Local development

Run `yarn storybook` from root. A local server will run, and any changes made to CSS and/or stories will auto-reload the page.

# Storybook config

Config files live in [.storybook](docs/.storybook)

[main.js](docs/.storybook/main.js): addons

[preview.js](docs/.storybook/preview.js): customizations, decorators, global CSS imports

[preview-head.html](docs/.storybook/preview-head.html): story-level "global" styles (within the story iframe)
20 changes: 10 additions & 10 deletions docs/src/variables.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import {Flex, Link, Text, Tooltip, Flash} from '@primer/components'
import Octicon, {AlertIcon} from '@primer/octicons-react'
import {AlertIcon} from '@primer/octicons-react'
import themeGet from '@styled-system/theme-get'
import DoctocatTable from '@primer/gatsby-theme-doctocat/src/components/table'
import styled from 'styled-components'
Expand Down Expand Up @@ -86,7 +86,7 @@ function Variables({children, ...props}) {
<>
<h2>No data available</h2>
{__DEV__ && (
<Flash scheme="red">
<Flash variant="danger">
This probably means that the root project has not been built; run `npm run dist` and restart your
development server.
</Flash>
Expand Down Expand Up @@ -121,17 +121,17 @@ function VariablesDetails({variablesByFile, ...props}) {
<tr id={name} key={name}>
<th scope="row">
<Flex justifyContent="space-between">
<Link href={`#${name}`} color="gray.4" mr={2}>
<Link href={`#${name}`} color="fg.muted" mr={2}>
#
</Link>
<Flex.Item flex="1">
<Flex flex="1">
<Link href={`https://github.com/primer/css/tree/main/${source.path}#L${source.line}`}>
<Mono nowrap>{name}</Mono>
</Link>
</Flex.Item>
<Flex.Item justifySelf="end">
</Flex>
<Flex justifySelf="end">
<DeprecationFlag variable={name} ml={2} />
</Flex.Item>
</Flex>
</Flex>
</th>
<td>
Expand Down Expand Up @@ -159,7 +159,7 @@ const SwatchBox = styled(Text)`
vertical-align: baseline;
width: ${p => p.size};
height: ${p => p.size};
border: 1px solid ${themeGet('colors.gray.3')};
border: 1px solid ${themeGet('colors.border.default')};
border-radius: ${themeGet('radii.1')}px;
margin-bottom: -2px;
`
Expand All @@ -183,8 +183,8 @@ function DeprecationFlag({variable, ...rest}) {

function DeprecationIcon() {
return (
<Text color="red.5">
<Octicon icon={AlertIcon} />
<Text color="danger.fg">
<AlertIcon />
</Text>
)
}
Expand Down
Loading

0 comments on commit 31f072e

Please sign in to comment.