-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c457e98
commit cfef44f
Showing
6 changed files
with
98 additions
and
103 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { Meta, StoryObj } from '@storybook/react' | ||
|
||
import Summary from './Summary' | ||
|
||
import TotalsNumber from '../TotalsNumber' | ||
|
||
const meta: Meta<typeof Summary> = { | ||
title: 'Components/Summary', | ||
component: Summary, | ||
} | ||
|
||
export default meta | ||
|
||
type Story = StoryObj<typeof Summary> | ||
|
||
export const DefaultSummary: Story = { | ||
args: { | ||
fields: [ | ||
{ | ||
name: 'sample title', | ||
title: 'Sample title', | ||
value: <span>Fancy markup</span>, | ||
}, | ||
], | ||
}, | ||
} | ||
|
||
export const SummaryManyFields: Story = { | ||
args: { | ||
fields: [ | ||
{ | ||
name: 'Head', | ||
title: ( | ||
<> | ||
<span>HEAD</span> | ||
<span className="text-ds-gray-octonary">fc43199</span> | ||
</> | ||
), | ||
value: <TotalsNumber value={39.67} plain large />, | ||
}, | ||
{ | ||
name: 'patch', | ||
title: 'Patch', | ||
value: <TotalsNumber value={83.43} plain large />, | ||
}, | ||
{ | ||
name: 'change', | ||
title: 'Change', | ||
value: <TotalsNumber value={27.36} showChange large />, | ||
}, | ||
], | ||
}, | ||
} |
22 changes: 9 additions & 13 deletions
22
src/ui/Summary/Summary.spec.jsx → src/ui/Summary/Summary.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Summary on Commit Detail and Compare using a config object instead of composition | ||
// The newer preferred way is to import the Summary root and field yourself per implementation. | ||
// | ||
// TODO: Update Commit Detail and Compare pages to use the composable summary components instead. | ||
|
||
interface Fields { | ||
name: string | ||
title?: React.ReactNode | ||
value: React.ReactNode | ||
} | ||
|
||
interface SummaryProps { | ||
fields?: Fields[] | ||
} | ||
|
||
const Summary: React.FC<SummaryProps> = ({ fields }) => { | ||
return fields && fields.length > 0 ? ( | ||
<div className="flex flex-wrap items-start justify-start gap-8 md:flex-nowrap"> | ||
{fields.map(({ name, title, value }) => { | ||
// Below changes is the original SummaryField markup | ||
return value ? ( | ||
<div key={name} className="flex flex-col justify-center gap-1"> | ||
{title ? ( | ||
<h4 className="flex gap-2 font-mono text-xs text-ds-gray-quinary"> | ||
{title} | ||
</h4> | ||
) : null} | ||
{value ? <div className="text-xl font-light">{value}</div> : null} | ||
</div> | ||
) : null | ||
})} | ||
</div> | ||
) : null | ||
} | ||
|
||
export default Summary |
File renamed without changes.