-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added typography to Span. Added universal typography base class '.dnb-t'
- Loading branch information
Showing
29 changed files
with
489 additions
and
143 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
13 changes: 13 additions & 0 deletions
13
packages/dnb-design-system-portal/src/docs/uilib/elements/span.mdx
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,13 @@ | ||
--- | ||
title: 'Span' | ||
theme: 'sbanken' | ||
showTabs: true | ||
hideTabs: | ||
- title: Events | ||
--- | ||
|
||
import SpanInfo from 'Docs/uilib/elements/span/info' | ||
import SpanDemos from 'Docs/uilib/elements/span/demos' | ||
|
||
<SpanInfo /> | ||
<SpanDemos /> |
79 changes: 79 additions & 0 deletions
79
packages/dnb-design-system-portal/src/docs/uilib/elements/span/Examples.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/** | ||
* UI lib Component Example | ||
* | ||
*/ | ||
|
||
import React from 'react' | ||
import ComponentBox from '../../../../shared/tags/ComponentBox' | ||
import Anchor from '@dnb/eufemia/src/components/Anchor' | ||
import { Span, P, H4 } from '@dnb/eufemia/src/elements' | ||
|
||
export function SpanBasic() { | ||
return ( | ||
<ComponentBox data-visual-test="span-basic"> | ||
<P> | ||
Here is a paragraph with a <Span size="x-small">x-small</Span> word | ||
and some <Span medium>medium weight text</Span> in it. | ||
</P> | ||
<H4> | ||
Heading 4 with <Span size="x-large">x-large</Span> word | ||
</H4> | ||
|
||
<Anchor href="/"> | ||
Anchor with <Span medium>medium weight</Span> words | ||
</Anchor> | ||
</ComponentBox> | ||
) | ||
} | ||
|
||
export function SpanModifiers() { | ||
return ( | ||
<ComponentBox data-visual-test="span-modifiers"> | ||
<div> | ||
<Span>Default span</Span> | ||
<br /> | ||
<Span modifier="medium">Medium weight span</Span> | ||
<br /> | ||
<Span size="small">Small span</Span> | ||
<br /> | ||
<Span modifier="small medium">Small span with medium weight</Span> | ||
<br /> | ||
{/* (Bold is currently not supported by DNB UX) */} | ||
{/* <Span modifier="bold">Bold weight span</Span> */} | ||
{/* <Span modifier="small bold">Small span with bold weight</Span> */} | ||
</div> | ||
</ComponentBox> | ||
) | ||
} | ||
|
||
export function SpanRegressionTests() { | ||
const SpanWrap = (props) => { | ||
const size = props.size || 'default' | ||
return ( | ||
<div> | ||
<Span {...props}>{size}</Span> | ||
<br /> | ||
<Span medium {...props}> | ||
{size} - Weight medium | ||
</Span> | ||
<br /> | ||
<Span bold {...props}> | ||
{size} - Weight bold | ||
</Span> | ||
</div> | ||
) | ||
} | ||
|
||
return ( | ||
<ComponentBox scope={{ SpanWrap }} data-visual-test="span-sizes"> | ||
<SpanWrap /> | ||
<SpanWrap size="xx-large" /> | ||
<SpanWrap size="x-large" /> | ||
<SpanWrap size="large" /> | ||
<SpanWrap size="medium" /> | ||
<SpanWrap size="basis" /> | ||
<SpanWrap size="small" /> | ||
<SpanWrap size="x-small" /> | ||
</ComponentBox> | ||
) | ||
} |
23 changes: 23 additions & 0 deletions
23
packages/dnb-design-system-portal/src/docs/uilib/elements/span/demos.mdx
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,23 @@ | ||
--- | ||
showTabs: true | ||
--- | ||
|
||
import { | ||
SpanBasic, | ||
SpanRegressionTests, | ||
SpanModifiers, | ||
} from 'Docs/uilib/elements/span/Examples' | ||
|
||
## Demos | ||
|
||
### Basics | ||
|
||
<SpanBasic /> | ||
|
||
### Span modifiers | ||
|
||
<SpanModifiers /> | ||
|
||
<VisibleWhenVisualTest> | ||
<SpanRegressionTests /> | ||
</VisibleWhenVisualTest> |
16 changes: 16 additions & 0 deletions
16
packages/dnb-design-system-portal/src/docs/uilib/elements/span/info.mdx
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,16 @@ | ||
--- | ||
showTabs: true | ||
--- | ||
|
||
## Import | ||
|
||
```tsx | ||
import { Span } from '@dnb/eufemia/elements' | ||
``` | ||
|
||
## Description | ||
|
||
`<Span>` are inline elements. They share typography props (for size and weight) with the [Paragraph component](/uilib/elements/paragraph). | ||
Unlike `<P>`, the `<Span>` component does not modify anything by default. | ||
|
||
Since `<Span>` is an inline element, it's easier to modify parts of text than it is with `<P>`. |
10 changes: 10 additions & 0 deletions
10
packages/dnb-design-system-portal/src/docs/uilib/elements/span/properties.mdx
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,10 @@ | ||
--- | ||
showTabs: true | ||
--- | ||
|
||
import PropertiesTable from 'dnb-design-system-portal/src/shared/parts/PropertiesTable' | ||
import { SpanProperties } from '@dnb/eufemia/src/elements/span/SpanDocs' | ||
|
||
## Properties | ||
|
||
<PropertiesTable props={SpanProperties} /> |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { PropertiesTableProps } from '../../shared/types' | ||
import { TypographyProperties } from '../typography/TypographyDocs' | ||
|
||
export const SpanProperties: PropertiesTableProps = { | ||
...TypographyProperties, | ||
} |
37 changes: 37 additions & 0 deletions
37
packages/dnb-eufemia/src/elements/span/__tests__/Span.screenshot.test.ts
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,37 @@ | ||
/** | ||
* Screenshot Test | ||
* This file will not run on "test:staged" because we don't require any related files | ||
*/ | ||
|
||
import { | ||
makeScreenshot, | ||
setupPageScreenshot, | ||
} from '../../../core/jest/jestSetupScreenshots' | ||
|
||
describe.each(['ui', 'sbanken'])('Span for %s', (themeName) => { | ||
setupPageScreenshot({ | ||
themeName, | ||
url: '/uilib/elements/span', | ||
}) | ||
|
||
it('basics', async () => { | ||
const screenshot = await makeScreenshot({ | ||
selector: '[data-visual-test="span-basic"]', | ||
}) | ||
expect(screenshot).toMatchImageSnapshot() | ||
}) | ||
|
||
it('with modifiers', async () => { | ||
const screenshot = await makeScreenshot({ | ||
selector: '[data-visual-test="span-modifiers"]', | ||
}) | ||
expect(screenshot).toMatchImageSnapshot() | ||
}) | ||
|
||
it('all sizes and weights', async () => { | ||
const screenshot = await makeScreenshot({ | ||
selector: '[data-visual-test="span-sizes"]', | ||
}) | ||
expect(screenshot).toMatchImageSnapshot() | ||
}) | ||
}) |
62 changes: 62 additions & 0 deletions
62
packages/dnb-eufemia/src/elements/span/__tests__/Span.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* Element Test | ||
* | ||
*/ | ||
|
||
import React from 'react' | ||
import { axeComponent } from '../../../core/jest/jestSetup' | ||
import Span from '../Span' | ||
import { render } from '@testing-library/react' | ||
|
||
describe('Span element', () => { | ||
it('has correct size when size is defined', () => { | ||
render(<Span size="large" />) | ||
const element = document.querySelector('.dnb-t__size--large') | ||
|
||
expect(Array.from(element.classList)).toEqual([ | ||
'dnb-t__size--large', | ||
'dnb-span', | ||
]) | ||
}) | ||
it('has correct style when size and a modifier is defined', () => { | ||
render(<Span size="medium" modifier="medium" />) | ||
const element = document.querySelector('.dnb-t__size--medium') | ||
|
||
expect(Array.from(element.classList)).toEqual([ | ||
'dnb-t--medium', | ||
'dnb-t__size--medium', | ||
'dnb-span', | ||
]) | ||
}) | ||
it('has correct style when several modifiers are defined', () => { | ||
render(<Span modifier="medium small" />) | ||
const element = document.querySelector('.dnb-t__size--small') | ||
|
||
expect(Array.from(element.classList)).toEqual([ | ||
'dnb-t--medium', | ||
'dnb-t__size--small', | ||
'dnb-span', | ||
]) | ||
}) | ||
it('has correct style when medium is set to true', () => { | ||
render(<Span medium />) | ||
const element = document.querySelector('.dnb-t--medium') | ||
expect(Array.from(element.classList)).toEqual([ | ||
'dnb-t--medium', | ||
'dnb-span', | ||
]) | ||
}) | ||
it('has correct style when bold is set to true', () => { | ||
render(<Span bold />) | ||
const element = document.querySelector('.dnb-t--bold') | ||
|
||
expect(Array.from(element.classList)).toEqual([ | ||
'dnb-t--bold', | ||
'dnb-span', | ||
]) | ||
}) | ||
it('should validate with ARIA rules as a span element', async () => { | ||
const Comp = render(<Span size="x-small" element="span" />) | ||
expect(await axeComponent(Comp)).toHaveNoViolations() | ||
}) | ||
}) |
Binary file added
BIN
+101 KB
...n/__tests__/__image_snapshots__/span-for-sbanken-all-sizes-and-weights.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+21.4 KB
...rc/elements/span/__tests__/__image_snapshots__/span-for-sbanken-basics.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.42 KB
...nts/span/__tests__/__image_snapshots__/span-for-sbanken-with-modifiers.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+87.1 KB
...s/span/__tests__/__image_snapshots__/span-for-ui-all-sizes-and-weights.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.8 KB
...mia/src/elements/span/__tests__/__image_snapshots__/span-for-ui-basics.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.59 KB
...elements/span/__tests__/__image_snapshots__/span-for-ui-with-modifiers.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,6 +1,6 @@ | ||
import { PropertiesTableProps } from '../../shared/types' | ||
import { ParagraphProperties } from './PDocs' | ||
import { TypographyProperties } from './TypographyDocs' | ||
|
||
export const IngressProperties: PropertiesTableProps = { | ||
...ParagraphProperties, | ||
...TypographyProperties, | ||
} |
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,6 +1,6 @@ | ||
import { PropertiesTableProps } from '../../shared/types' | ||
import { ParagraphProperties } from './PDocs' | ||
import { TypographyProperties } from './TypographyDocs' | ||
|
||
export const LeadProperties: PropertiesTableProps = { | ||
...ParagraphProperties, | ||
...TypographyProperties, | ||
} |
Oops, something went wrong.