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

Type check tests and stories in CI #1960

Merged
merged 13 commits into from
Mar 15, 2022
5 changes: 5 additions & 0 deletions .changeset/funny-ears-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

Checkbox: `value` prop is now optional
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ jobs:

- name: Test
run: npm run test

- name: Type check
run: npm run test:type-check
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"lint:fix": "npm run lint -- --fix",
"test": "jest",
"test:update": "npm run test -- --updateSnapshot",
"test:type-check": "tsc --noEmit",
"release": "npm run build && changeset publish",
"size": "size-limit",
"prepare": "husky install"
Expand Down
104 changes: 52 additions & 52 deletions src/Button/Button2.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, {useState, forwardRef} from 'react'
import {Button, ButtonProps, IconButton, LinkButton} from '.'
import {BaseStyles, ThemeProvider} from '..'
import {EyeClosedIcon, EyeIcon, SearchIcon, TriangleDownIcon, XIcon} from '@primer/octicons-react'
import {Meta} from '@storybook/react'
import {XIcon, SearchIcon, EyeIcon, EyeClosedIcon, TriangleDownIcon, TriangleRightIcon} from '@primer/octicons-react'
import React, {useState} from 'react'
import {Button, ButtonProps, IconButton} from '.'
import {BaseStyles, ThemeProvider} from '..'
import Box from '../Box'

export default {
Expand Down Expand Up @@ -186,52 +186,52 @@ export const disabledButton = ({...args}: ButtonProps) => {
)
}

type ReactRouterLikeLinkProps = {to: string; children: React.ReactNode}
const ReactRouterLikeLink = forwardRef<HTMLAnchorElement, ReactRouterLikeLinkProps>(
({to, ...props}: {to: string; children: React.ReactNode}, ref) => {
// eslint-disable-next-line jsx-a11y/anchor-has-content
return <a ref={ref} href={to} {...props} />
}
)
// type ReactRouterLikeLinkProps = {to: string; children: React.ReactNode}
// const ReactRouterLikeLink = forwardRef<HTMLAnchorElement, ReactRouterLikeLinkProps>(
// ({to, ...props}: {to: string; children: React.ReactNode}, ref) => {
// // eslint-disable-next-line jsx-a11y/anchor-has-content
// return <a ref={ref} href={to} {...props} />
// }
// )

export const linkButton = ({...args}: ButtonProps) => {
return (
<>
<Box mb={2} display="flex">
<LinkButton href="https://primer.style/" {...args}>
Link to Primer
</LinkButton>
</Box>
<Box mb={2} display="flex">
<LinkButton href="https://primer.style/" variant="danger" {...args}>
Link to Primer
</LinkButton>
</Box>
<Box mb={2} display="flex">
<LinkButton href="https://primer.style/" variant="primary" {...args}>
Link to Primer
</LinkButton>
</Box>
<Box mb={2} display="flex">
<LinkButton href="https://primer.style/" variant="outline" {...args}>
Link to Primer
</LinkButton>
</Box>
<Box mb={2} display="flex">
<LinkButton href="https://primer.style/" variant="invisible" {...args}>
Link to Primer
</LinkButton>
</Box>
<Box mb={2} display="flex">
<LinkButton href="https://primer.style/" variant="primary" trailingIcon={TriangleRightIcon} {...args}>
Link to Primer
</LinkButton>
</Box>
<Box mb={2} display="flex">
<LinkButton to="/dummy" as={ReactRouterLikeLink} variant="primary" trailingIcon={TriangleRightIcon} {...args}>
Link to Primer
</LinkButton>
</Box>
</>
)
}
// export const linkButton = ({...args}: ButtonProps) => {
// return (
// <>
// <Box mb={2} display="flex">
// <LinkButton href="https://primer.style/" {...args}>
// Link to Primer
// </LinkButton>
// </Box>
// <Box mb={2} display="flex">
// <LinkButton href="https://primer.style/" variant="danger" {...args}>
// Link to Primer
// </LinkButton>
// </Box>
// <Box mb={2} display="flex">
// <LinkButton href="https://primer.style/" variant="primary" {...args}>
// Link to Primer
// </LinkButton>
// </Box>
// <Box mb={2} display="flex">
// <LinkButton href="https://primer.style/" variant="outline" {...args}>
// Link to Primer
// </LinkButton>
// </Box>
// <Box mb={2} display="flex">
// <LinkButton href="https://primer.style/" variant="invisible" {...args}>
// Link to Primer
// </LinkButton>
// </Box>
// <Box mb={2} display="flex">
// <LinkButton href="https://primer.style/" variant="primary" trailingIcon={TriangleRightIcon} {...args}>
// Link to Primer
// </LinkButton>
// </Box>
// <Box mb={2} display="flex">
// <LinkButton to="/dummy" as={ReactRouterLikeLink} variant="primary" trailingIcon={TriangleRightIcon} {...args}>
// Link to Primer
// </LinkButton>
// </Box>
// </>
// )
// }
2 changes: 1 addition & 1 deletion src/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export type CheckboxProps = {
* A unique value that is never shown to the user.
* Used during form submission and to identify which checkbox inputs are selected
*/
value: string
value?: string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this @colebemis 🙇

} & Exclude<InputHTMLAttributes<HTMLInputElement>, 'value'> &
SxProp

Expand Down
3 changes: 1 addition & 2 deletions src/PageLayout/PageLayout.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {Meta, Story} from '@storybook/react'
import React from 'react'
import {Box, BranchName, Heading, Link, SideNav, StateLabel, TabNav, Text} from '..'
import {Button} from '../drafts'
import {Box, BranchName, Heading, Link, SideNav, StateLabel, TabNav, Text, Button} from '..'
import {Placeholder} from '../Placeholder'
import {PageLayout} from './PageLayout'

Expand Down
6 changes: 3 additions & 3 deletions src/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import styled from 'styled-components'
import {get} from './constants'
import TextInputWrapper, {StyledWrapperProps} from './_TextInputWrapper'

type SelectProps = Omit<
Omit<React.HTMLProps<HTMLSelectElement>, 'size'> & Omit<StyledWrapperProps, 'variant'>,
export type SelectProps = Omit<
Omit<React.ComponentPropsWithoutRef<'select'>, 'size'> & Omit<StyledWrapperProps, 'variant'>,
'multiple' | 'hasLeadingVisual' | 'hasTrailingVisual' | 'as'
>

Expand Down Expand Up @@ -42,7 +42,7 @@ const ArrowIndicator = styled(ArrowIndicatorSVG)`
`

const Select = React.forwardRef<HTMLSelectElement, SelectProps>(
({children, disabled, placeholder, size, required, validationStatus, ref: _propsRef, ...rest}: SelectProps, ref) => (
({children, disabled, placeholder, size, required, validationStatus, ...rest}: SelectProps, ref) => (
<TextInputWrapper
sx={{
position: 'relative'
Expand Down
1 change: 0 additions & 1 deletion src/__tests__/LabelGroup.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const comp = (
<LabelGroup>
<Label>Default label</Label>
<Label>Darker gray label</Label>
<Label outline>Default outline label</Label>
</LabelGroup>
)

Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/deprecated/Label.types.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import Label from '../deprecated/Label'
import Label from '../../deprecated/Label'

export function shouldAcceptCallWithNoProps() {
return <Label />
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export {default as ProgressBar} from './ProgressBar'
export type {ProgressBarProps} from './ProgressBar'
export {default as RadioGroup} from './RadioGroup'
export {default as Select} from './Select'
export type {SelectProps} from './Select'
export {SelectPanel} from './SelectPanel'
export type {SelectPanelProps} from './SelectPanel'
export {default as SideNav} from './SideNav'
Expand Down
6 changes: 1 addition & 5 deletions src/stories/ActionMenu/fixtures.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,7 @@ const LayoutToggleItem = ({
}
}}
>
<FormControl.Label
htmlFor="layout-selector"
sx={{fontWeight: 'normal', cursor: 'pointer', px: 3, py: 2, mb: 0}}
{...props}
>
<FormControl.Label sx={{fontWeight: 'normal', cursor: 'pointer', px: 3, py: 2, mb: 0}} {...props}>
<Box sx={{textAlign: 'center', flexDirection: 'column', m: 'auto', alignItems: 'center', display: 'flex'}}>
<Icon size="medium" />
<Text sx={{color: selected ? 'fg.default' : 'fg.muted', fontSize: 0}}>{children}</Text>
Expand Down
6 changes: 1 addition & 5 deletions src/stories/deprecated/ActionList.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,7 @@ export function CustomItemChildren(): JSX.Element {
items={[
{
leadingVisual: ArrowRightIcon,
children: (
<Label outline borderColor="success.emphasis">
Choose this one
</Label>
),
children: <Label>Choose this one</Label>,
trailingIcon: ArrowLeftIcon
}
]}
Expand Down
2 changes: 1 addition & 1 deletion src/stories/useAnchoredPosition.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import styled from 'styled-components'
import {get} from '../constants'
import type {AnchorSide} from '@primer/behaviors'
import Portal, {registerPortalRoot} from '../Portal'
import Button from '../Button'
import {Button} from '../Button'

export default {
title: 'Hooks/useAnchoredPosition',
Expand Down
3 changes: 3 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"emitDeclarationOnly": true
},
// NOTE: We exclude Storybook stories and test utilities which import
// Storybook and its dependencies, because:
// a) we don't want Storybook types in our build output, and
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"jsx": "preserve",
"declaration": true,
"outDir": "./lib",
"emitDeclarationOnly": true,
"strict": true,
"moduleResolution": "node",
"rootDirs": ["src"],
Expand Down