-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: improve formatters documentation
- Loading branch information
Showing
16 changed files
with
92 additions
and
289 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,35 +1,92 @@ | ||
import { Meta } from '@storybook/blocks'; | ||
import { Table, TableHead, TableRow, TableDataCell, TableHeaderCell, TableBody, TableCaption } from "@sb1/ffe-tables-react"; | ||
import { | ||
Table, | ||
TableHead, | ||
TableRow, | ||
TableDataCell, | ||
TableHeaderCell, | ||
TableBody, | ||
TableCaption, | ||
} from '@sb1/ffe-tables-react'; | ||
import { formatAccountNumber } from './formatAccountNumber'; | ||
import { formatDate } from './formatDate'; | ||
import { formatNumber } from './formatNumber'; | ||
import { formatCurrency } from './formatCurrency'; | ||
import { formatPercentage } from './formatPercentage'; | ||
import { formatFodselsnummer } from './formatFodselsnummer'; | ||
import { formatDistance } from './formatDistance'; | ||
import { InstallImport } from '../../../documentation/components/InstallImport'; | ||
|
||
<Meta title="Komponenter/Formatters/Formatering" /> | ||
<Meta title="Utils/Formatters" /> | ||
|
||
# Formateringsprinsipper | ||
|
||
<InstallImport dependencies={['@sb1/ffe-formatters']} nocore /> | ||
|
||
Det finnes mange formateringsprinsipper som er standardisert i Norge, og som bidrar til å øke lesbarheten. I designsystemet har vi komponenter som hjelper med formateringen, så du som utvikler ikke trenger å bekymre deg for at ting ikke vises riktig. | ||
|
||
<Table className="sb-unstyled"> | ||
<TableCaption className="sb-unstyled">Utvalg av ulike formateringer som finnes:</TableCaption> | ||
<TableCaption className="sb-unstyled"> | ||
Utvalg av ulike formateringer som finnes: | ||
</TableCaption> | ||
<TableHead className="sb-unstyled"> | ||
<TableRow className="sb-unstyled"> | ||
<TableHeaderCell className="sb-unstyled">Type</TableHeaderCell> | ||
<TableHeaderCell className="sb-unstyled">Funksjon</TableHeaderCell> | ||
<TableHeaderCell className="sb-unstyled">Eksempel</TableHeaderCell> | ||
<TableHeaderCell className="sb-unstyled">Resultat</TableHeaderCell> | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{[ | ||
{type :'Datoer', eksempel: '12.11.2024'}, | ||
{type :'Tall', eksempel: '100 000'}, | ||
{type :'Valuta', eksempel: 'kr 1 000,–'}, | ||
{type :'Prosenter', eksempel: '7 %'}, | ||
{type :'Kontonummer', eksempel: '1234 56 78901'}, | ||
{type :'Fødselsnummer', eksempel: '123456 78901'}, | ||
{type :'Avstander', eksempel: '50 km'}, | ||
].map((it) => ( | ||
{ | ||
type: 'Datoer', | ||
eksempel: 1731366000000, | ||
ekstraEksempel: 'new Date(2024, 10, 12)', | ||
func: formatDate, | ||
}, | ||
{ | ||
type: 'Tall', | ||
func: formatNumber, | ||
eksempel: 100000, | ||
opts: { locale: 'nb' }, | ||
}, | ||
{ | ||
type: 'Valuta', | ||
eksempel: '1000', | ||
func: formatCurrency, | ||
opts: { locale: 'nb' }, | ||
}, | ||
{ type: 'Prosenter', eksempel: '7', func: formatPercentage }, | ||
{ | ||
type: 'Kontonummer', | ||
eksempel: '12345678901', | ||
func: formatAccountNumber, | ||
}, | ||
{ | ||
type: 'Fødselsnummer', | ||
eksempel: '12345678901', | ||
func: formatFodselsnummer, | ||
}, | ||
{ type: 'Avstander', eksempel: '50', func: formatDistance }, | ||
].map(it => ( | ||
<TableRow className="sb-unstyled" key={it.type}> | ||
<TableDataCell className="sb-unstyled">{it.type}</TableDataCell> | ||
<TableDataCell className="sb-unstyled">{it.eksempel}</TableDataCell> | ||
<TableDataCell className="sb-unstyled"> | ||
<code>{it.func?.name}</code> | ||
</TableDataCell> | ||
<TableDataCell className="sb-unstyled"> | ||
{it.eksempel} | ||
{it.ekstraEksempel && ( | ||
<> | ||
/ <br /> {it.ekstraEksempel} | ||
</> | ||
)} | ||
</TableDataCell> | ||
<TableDataCell className="sb-unstyled"> | ||
{it.func?.(it.eksempel, it.opts)} | ||
</TableDataCell> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
|
22 changes: 0 additions & 22 deletions
22
packages/ffe-formatters/src/formatAccountNumber.stories.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
packages/ffe-formatters/src/formatFodselsnummer.stories.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.