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

RelativeTime: Remove title from Storybook stories #5685

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,54 @@ import React from 'react'
import RelativeTime from './RelativeTime'
import Link from '../Link'
import {Tooltip} from '../TooltipV2'
import {Button} from '../Button'
import {Stack} from '../Stack'

export default {
title: 'Components/RelativeTime/Examples',
component: RelativeTime,
}

export const NoTitleAttribute = () => <RelativeTime date={new Date('2020-01-01T00:00:00Z')} noTitle={true} />
export const DynamicRelativeTime = () => {
const [time, setTime] = React.useState(false)
return (
<Stack>
<div>
<Button onClick={() => setTime(!time)} aria-describedby="relative-time">
Show {time ? 'short' : 'exact'} date
</Button>
</div>
<div>
<RelativeTime
id="relative-time"
date={new Date('2020-01-01T00:00:00Z')}
minute={time ? '2-digit' : undefined}
hour={time ? 'numeric' : undefined}
day={time ? '2-digit' : undefined}
month={time ? 'short' : undefined}
year={time ? 'numeric' : undefined}
timeZoneName={time ? 'short' : undefined}
prefix=""
noTitle
/>
</div>
</Stack>
)
}

export const LongDate = () => (
<RelativeTime
date={new Date('2020-01-01T00:00:00Z')}
minute="2-digit"
hour="numeric"
day="2-digit"
month="short"
year="numeric"
timeZoneName="short"
prefix=""
noTitle
/>
)

export const LinkWithTooltip = () => (
<Tooltip text={new Date('2020-01-01T00:00:00Z').toString()}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,20 @@ const meta: Meta = {

export const MicroFormat: StoryFn = args => {
const {date, ...rest} = args
return <RelativeTime {...rest} date={new Date(date)} format="micro" />
return <RelativeTime noTitle={true} {...rest} date={new Date(date)} format="micro" />
}
MicroFormat.args = {tense: 'past'}
MicroFormat.argTypes = {format: {control: false}}

export const RecentTime: StoryFn = args => {
const {...rest} = args
return <RelativeTime {...rest} date={new Date()} />
return <RelativeTime noTitle={true} {...rest} date={new Date()} />
}
RecentTime.argTypes = {date: {control: false}}

export const CountDownTimer: StoryFn = args => {
const {...rest} = args
return <RelativeTime {...rest} />
return <RelativeTime noTitle={true} {...rest} />
}
CountDownTimer.args = {date: new Date('2038-01-19T03:14:08Z'), format: 'elapsed', day: '', month: ''}
CountDownTimer.argTypes = {date: {control: false}, format: {control: false}}
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/RelativeTime/RelativeTime.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const Default: StoryFn = () => <RelativeTime date={new Date('2020-01-01T0

export const Playground: StoryFn = args => {
const {date, ...rest} = args
return <RelativeTime {...rest} date={new Date(date)} />
return <RelativeTime noTitle={true} {...rest} date={new Date(date)} />
}

Playground.args = {
Expand Down
Loading