Skip to content
Closed
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
15 changes: 15 additions & 0 deletions site/src/components/AuditLog/TimeCell.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { ComponentMeta, Story } from "@storybook/react"
import React from "react"
import { TimeCell, TimeCellProps } from "./TimeCell"

export default {
title: "AuditLog/Cells/TimeCell",
component: TimeCell,
} as ComponentMeta<typeof TimeCell>

const Template: Story<TimeCellProps> = (args) => <TimeCell {...args} />

export const Example = Template.bind({})
Example.args = {
date: new Date(),
}
25 changes: 25 additions & 0 deletions site/src/components/AuditLog/TimeCell.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Box from "@material-ui/core/Box"
import Typography from "@material-ui/core/Typography"
import React from "react"

export interface TimeCellProps {
date: Date
}
export namespace TimeCellProps {
export const displayTime = (props: TimeCellProps): string => {
return props.date.toLocaleTimeString()
}

export const displayDate = (props: TimeCellProps): string => {
return props.date.toLocaleDateString().replace(/\//g, ".")
Copy link
Contributor

Choose a reason for hiding this comment

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

Never thought about this before, but why do we use periods in dates?

}
}

export const TimeCell: React.FC<TimeCellProps> = (props) => {
return (
<Box display="flex" flexDirection="column">
<Typography>{TimeCellProps.displayTime(props)}</Typography>
<Typography variant="caption">{TimeCellProps.displayDate(props)}</Typography>
</Box>
)
}