Skip to content

Commit

Permalink
Fix className props
Browse files Browse the repository at this point in the history
  • Loading branch information
icaraps committed Jul 8, 2020
1 parent 71c7424 commit 9bb94f0
Show file tree
Hide file tree
Showing 19 changed files with 62 additions and 38 deletions.
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package.json
example/*
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"arrowParens": "avoid",
"semi": false
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
"version": "0.0.1",
"workspaces": ["example", "packages/*"],
"scripts": {
"start": "npm run build && npm run serve",
"dev": "yarn workspace example develop",
"build": "yarn workspace example build",
"serve": "yarn workspace example serve",
"clean": "yarn workspace example clean"
"clean": "yarn workspace example clean",
"format": "prettier --write '**/*.{js,json}'"
}
}
1 change: 1 addition & 0 deletions packages/gatsby-theme-spectrum/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@spectrum-css/typography": "^2.1.3",
"@spectrum-css/well": "^3.0.0-beta.2",
"@spectrum-icons/workflow": "^3.0.0",
"classnames": "^2.2.6",
"gatsby-plugin-catch-links": "^2.3.7",
"gatsby-plugin-emotion": "^4.3.6",
"gatsby-plugin-mdx": "^1.2.19",
Expand Down
7 changes: 4 additions & 3 deletions packages/gatsby-theme-spectrum/src/components/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@

import React from 'react';
import PropTypes from 'prop-types';
import '@spectrum-css/button/dist/index-vars.css';
import classNames from 'classnames';
import '@spectrum-css/button';

const Button = ({children, variant, isQuiet, ...props}) => (
<button {...props} className={`spectrum-Button spectrum-Button--${variant} ${isQuiet ? 'spectrum-Button--quiet' : ''}`}>{children}</button>
const Button = ({children, variant, isQuiet, className, ...props}) => (
<button {...props} className={classNames(className, ['spectrum-Button', `spectrum-Button--${variant}`, {'spectrum-Button--quiet': isQuiet}])}>{children}</button>
);

Button.propTypes = {
Expand Down
7 changes: 4 additions & 3 deletions packages/gatsby-theme-spectrum/src/components/Code.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
*/

import React from 'react';
import '@spectrum-css/typography/dist/index-vars.css';
import '@spectrum-css/typography';
import classNames from 'classnames';

export const Code = ({children, ...props}) => (
<code {...props} className="spectrum-Code4">{children}</code>
export const Code = ({children, className, ...props}) => (
<code {...props} className={classNames(className, 'spectrum-Code4')}>{children}</code>
)
11 changes: 8 additions & 3 deletions packages/gatsby-theme-spectrum/src/components/Feedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,20 @@ import React from 'react';
import {css} from '@emotion/core';
import PropTypes from 'prop-types';
import {Flex} from '@react-spectrum/layout';
import {View} from '@react-spectrum/view';
import {Button} from "./Button";
import '@spectrum-css/button/dist/index-vars.css';
import '@spectrum-css/button';

const Feedback = ({onYes, onNo}) => (
<Flex alignItems="center">
<span css={css`padding-right: var(--spectrum-global-dimension-static-size-200);`}>Was this helpful ?</span>
<Flex gap="size-200">
<Button variant="primary" onClick={() => {onYes && onYes()}}>Yes</Button>
<Button variant="primary" onClick={() => {onNo && onNo()}}>No</Button>
<View>
<Button variant="primary" onClick={() => {onYes && onYes()}}>Yes</Button>
</View>
<View>
<Button variant="primary" onClick={() => {onNo && onNo()}}>No</Button>
</View>
</Flex>
</Flex>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-theme-spectrum/src/components/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {css} from '@emotion/core';
import {Flex} from '@react-spectrum/layout';
import {View} from '@react-spectrum/view';
import {Divider} from '@react-spectrum/divider';
import '@spectrum-css/typography/dist/index-vars.css';
import '@spectrum-css/typography';

export const Footer = () => (
<footer
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-theme-spectrum/src/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import {css} from '@emotion/core';
import {Grid, Flex} from '@react-spectrum/layout';
import {View} from '@react-spectrum/view';
import {Button} from './Button';
import '@spectrum-css/typography/dist/index-vars.css';
import '@spectrum-css/tabs/dist/index-vars.css';
import '@spectrum-css/typography';
import '@spectrum-css/tabs';

const stretched = css`
height: 100%;
Expand Down
7 changes: 4 additions & 3 deletions packages/gatsby-theme-spectrum/src/components/Heading1.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
*/

import React from 'react';
import '@spectrum-css/typography/dist/index-vars.css';
import classNames from 'classnames';
import '@spectrum-css/typography';

export const Heading1 = ({children, ...props}) => (
<h1 {...props} className="spectrum-Heading--XXXL">
export const Heading1 = ({children, className, ...props}) => (
<h1 {...props} className={classNames(className, 'spectrum-Heading--XXXL')}>
{children}
</h1>
);
7 changes: 4 additions & 3 deletions packages/gatsby-theme-spectrum/src/components/Heading2.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@

import React from 'react';
import {css} from '@emotion/core';
import '@spectrum-css/typography/dist/index-vars.css';
import classNames from 'classnames';
import '@spectrum-css/typography';
import {Divider} from '@react-spectrum/divider';
import {Link} from './Link';

export const Heading2 = ({children, ...props}) => (
export const Heading2 = ({children, className, ...props}) => (
<>
<h2
{...props}
className="spectrum-Heading--L"
className={classNames(className, 'spectrum-Heading--L')}
css={css`
& a {
visibility: hidden;
Expand Down
7 changes: 4 additions & 3 deletions packages/gatsby-theme-spectrum/src/components/Heading3.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@

import React from 'react';
import {css} from '@emotion/core';
import '@spectrum-css/typography/dist/index-vars.css';
import classNames from 'classnames';
import '@spectrum-css/typography';
import {Link} from './Link';

export const Heading3 = ({children, ...props}) => (
export const Heading3 = ({children, className, ...props}) => (
<>
<h3
{...props}
className="spectrum-Heading--M"
className={classNames(className, 'spectrum-Heading--M')}
css={css`
& a {
visibility: hidden;
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-theme-spectrum/src/components/Hero.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import React from 'react';
import {css} from '@emotion/core';
import {Flex} from '@react-spectrum/layout';
import {View} from '@react-spectrum/view';
import '@spectrum-css/typography/dist/index-vars.css';
import '@spectrum-css/typography';

export const Hero = ({heading, text, illustration, background}) => (
<section css={css`
Expand Down
3 changes: 2 additions & 1 deletion packages/gatsby-theme-spectrum/src/components/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
import React from 'react';
import {css} from '@emotion/core';

export const Image = ({alt, src}) => (
export const Image = ({alt, src, ...props}) => (
<img
{...props}
alt={alt}
src={src}
css={css`
Expand Down
9 changes: 5 additions & 4 deletions packages/gatsby-theme-spectrum/src/components/InlineCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@

import React from 'react';
import {css} from '@emotion/core';
import '@spectrum-css/typography/dist/index-vars.css';
import '@spectrum-css/well/dist/index-vars.css';
import classNames from 'classnames';
import '@spectrum-css/typography';
import '@spectrum-css/well';

export const InlineCode = ({children, ...props}) => (
export const InlineCode = ({children, className, ...props}) => (
<code {...props}
className="spectrum-Code4 spectrum-Well"
className={classNames(className, 'spectrum-Code4', 'spectrum-Well')}
css={css`
padding: 0 var(--spectrum-global-dimension-static-size-50);
display: inline-block;
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-theme-spectrum/src/components/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {theme} from '@react-spectrum/theme-default';
import {Grid, Flex} from '@react-spectrum/layout';
import {View} from '@react-spectrum/view';
import LinkOut from '@spectrum-icons/workflow/LinkOut';
import '@spectrum-css/typography/dist/index-vars.css';
import '@spectrum-css/typography';

import {Header} from './Header';
import {Hero} from './Hero';
Expand Down
7 changes: 4 additions & 3 deletions packages/gatsby-theme-spectrum/src/components/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
// todo use https://www.gatsbyjs.org/docs/gatsby-link/ and check https://www.gatsbyjs.org/docs/path-prefix/

import React from 'react';
import '@spectrum-css/link/dist/index-vars.css';
import '@spectrum-css/link';
import classNames from 'classnames';

export const Link = ({children, ...props}) => (
<a className="spectrum-Link" {...props}>{children}</a>
export const Link = ({children, className, ...props}) => (
<a {...props} className={classNames(className, 'spectrum-Link')}>{children}</a>
)
7 changes: 4 additions & 3 deletions packages/gatsby-theme-spectrum/src/components/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
*/

import React from 'react';
import '@spectrum-css/typography/dist/index-vars.css';
import classNames from 'classnames';
import '@spectrum-css/typography';

export const List = ({children, ...props}) => (
<ul {...props} className="spectrum-Body--M">{children}</ul>
export const List = ({children, className, ...props}) => (
<ul {...props} className={classNames(className, 'spectrum-Body--M')}>{children}</ul>
);
7 changes: 4 additions & 3 deletions packages/gatsby-theme-spectrum/src/components/Paragraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
*/

import React from 'react';
import '@spectrum-css/typography/dist/index-vars.css';
import classNames from 'classnames';
import '@spectrum-css/typography';

export const Paragraph = ({children, ...props}) => (
<p {...props} className="spectrum-Body--M">{children}</p>
export const Paragraph = ({children, className, ...props}) => (
<p {...props} className={classNames(className, 'spectrum-Body--M')}>{children}</p>
);

0 comments on commit 9bb94f0

Please sign in to comment.