-
Notifications
You must be signed in to change notification settings - Fork 0
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
add TypeScript #992
add TypeScript #992
Changes from 16 commits
0501f7d
bcb1552
312b0ed
f287df0
2acf3da
4227332
92d1db8
304fae4
2b37511
83121bd
8faf10f
bacf545
1b1ef10
740af68
1922978
fc9495c
3fd618d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from 'react'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { faPlus } from '@fortawesome/pro-regular-svg-icons'; | ||
|
||
import Button from 'src/Button'; | ||
|
||
import EmptyState from './EmptyState'; | ||
|
||
const meta: Meta<typeof EmptyState> = { | ||
component: EmptyState, | ||
title: 'Components/EmptyState', | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof EmptyState>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
subtitle: 'Launch your first project to start conducting research!', | ||
title: 'You have no projects', | ||
} | ||
}; | ||
|
||
export const PrimaryAction: Story = { | ||
args: { | ||
primaryAction: <Button leadingIcon={faPlus} variant="primary">New project</Button>, | ||
subtitle: 'Launch your first project to start conducting research! Source from a pool of 2.4 million participants to reach nearly any target audience.', | ||
title: 'You have no projects', | ||
} | ||
}; | ||
|
||
export const FullWidth: Story = { | ||
args: { | ||
fullWidth: true, | ||
primaryAction: <Button leadingIcon={faPlus} variant="primary">New project</Button>, | ||
subtitle: 'Launch your first project to start conducting research! Source from a pool of 2.4 million participants to reach nearly any target audience.', | ||
title: 'You have no projects', | ||
} | ||
}; | ||
|
||
export const MarginTop: Story = { | ||
args: { | ||
marginTop: 'sm', | ||
subtitle: 'Add a new participant segment above', | ||
title: 'No segments created', | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React, { ReactNode } from 'react'; | ||
|
||
import classNames from 'classnames'; | ||
|
||
import { Heading } from '../Heading'; | ||
import { Text } from '../Text'; | ||
|
||
import './EmptyState.scss'; | ||
|
||
export interface EmptyStateProps { | ||
className?: string; | ||
fullWidth?: boolean; | ||
marginTop?: 'sm' | 'md' | 'lg' | 'none'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice that TS builds in enums like this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea this is part of what is going to make TS in the DS incredibly useful over in rails server. FYI this is actually a union of literals, and an enum exactly: https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types But TS does have some awesome enums as well: |
||
primaryAction?: ReactNode; | ||
subtitle?: string | ReactNode; | ||
title?: ReactNode; | ||
} | ||
|
||
const EmptyState = ({ | ||
className, | ||
fullWidth = false, | ||
marginTop = 'sm', | ||
Comment on lines
+21
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. put default props here that used to be on propTypes |
||
primaryAction, | ||
subtitle, | ||
title, | ||
}: EmptyStateProps) => ( | ||
<div className={classNames( | ||
className, | ||
'EmptyState', | ||
marginTop && `EmptyState--margin-top--${marginTop}`, | ||
)} | ||
> | ||
<div className={classNames( | ||
'EmptyState__content', | ||
fullWidth && 'EmptyState--full-width', | ||
)} | ||
> | ||
{title && ( | ||
<Heading className="EmptyState__title" level={4} size="lg" textAlign="center">{title}</Heading> | ||
)} | ||
|
||
{subtitle && ( | ||
<Text className="EmptyState__subtitle" textAlign="center">{subtitle}</Text> | ||
)} | ||
|
||
{primaryAction && ( | ||
<div className="EmptyState__actions"> | ||
<div className="EmptyState__actions__primary-action"> | ||
{primaryAction} | ||
</div> | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
|
||
export default EmptyState; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are react libraries not version-matched? ie. react-dom would also be 16.x
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not entirely sure. I followed what we were already using on RS, but maybe @kyleshike would know?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yikes yea these should be version matched. I guess it hasn't come up because all the react-dom stuff is happening under the hood with
react-rails
over in rails-server