diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/section/Examples.js b/packages/dnb-design-system-portal/src/docs/uilib/components/section/Examples.js index 596b89c4e5d..335759e0ce6 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/section/Examples.js +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/section/Examples.js @@ -11,7 +11,7 @@ export const SectionDemo = () => ( { /* jsx */ `
-

Visual DNB Section: default

+

Visual DNB Section: default

` } @@ -22,7 +22,7 @@ export const SectionDemoSpacing = () => ( { /* jsx */ ` -
+

Visual DNB Section: default with spacing

` @@ -34,7 +34,7 @@ export const SectionDemoWhite = () => ( { /* jsx */ ` -
+

Visual DNB Section: white

` @@ -46,7 +46,7 @@ export const SectionDemoDivider = () => ( { /* jsx */ ` -
+

Visual DNB Section: divider

` @@ -58,7 +58,7 @@ export const SectionDemoMintGreen = () => ( { /* jsx */ ` -
+

Visual DNB Section: mint-green

` @@ -70,7 +70,7 @@ export const SectionDemoSeaGreen = () => ( { /* jsx */ ` -
+

Visual DNB Section: sea-green

` @@ -82,7 +82,7 @@ export const SectionDemoEmeraldGreen = () => ( { /* jsx */ ` -
+

Visual DNB Section: emerald-green

` @@ -94,7 +94,7 @@ export const SectionDemoLavender = () => ( { /* jsx */ ` -
+

Visual DNB Section: lavender

` @@ -106,7 +106,7 @@ export const SectionDemoBlack3 = () => ( { /* jsx */ ` -
+

Visual DNB Section: black-3

` @@ -118,7 +118,7 @@ export const SectionDemoSandYellow = () => ( { /* jsx */ ` -
+

Visual DNB Section: sand-yellow

` @@ -130,7 +130,7 @@ export const SectionDemoPistachio = () => ( { /* jsx */ ` -
+

Visual DNB Section: pistachio

` @@ -142,7 +142,7 @@ export const SectionDemoFireRed = () => ( { /* jsx */ ` -
+

Visual DNB Section: fire-red

` @@ -154,7 +154,7 @@ export const SectionDemoFireRed8 = () => ( { /* jsx */ ` -
+

Visual DNB Section: fire-red-8

` diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/section/properties.md b/packages/dnb-design-system-portal/src/docs/uilib/components/section/properties.md index 31b1b43d8ca..29c638e0f31 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/section/properties.md +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/section/properties.md @@ -4,12 +4,13 @@ showTabs: true ## Properties -| Properties | Description | -| ------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `style_type` | _(optional)_ to define the style of the visual helper. Use and `Style ID` from below. Defaults to `mint-green-12`. | -| `spacing` | _(optional)_ will add the default spacing around the wrapped content. Use `spacing-large`, `spacing-medium` or `spacing-small`. Defaults to `false`. If `true`, then `spacing-default` is used. Se the [available sizes](/uilib/usage/layout/spacing#spacing-helpers). | -| `element` | _(optional)_ define what HTML element should be used. Defaults to `
`. | -| [Space](/uilib/components/space/properties) | _(optional)_ spacing properties like `top` or `bottom` are supported. | +| Properties | Description | +| ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `style_type` | _(optional)_ to define the style of the visual helper. Use and `Style ID` from below. Defaults to `mint-green-12`. | +| `spacing` | _(optional)_ will add the default spacing around the wrapped content. Use `large`, `medium` or `small`. Defaults to `false`. If `true`, then `large` is used. Se the [available sizes](/uilib/usage/layout/spacing#spacing-helpers). | +| `element` | _(optional)_ define what HTML element should be used. Defaults to `
`. | +| `inner_ref` | _(optional)_ by providing a React Ref we can get the internally used element (DOM). E.g. `inner_ref={myRef}` by using `React.createRef()` or `React.useRef()`. | +| [Space](/uilib/components/space/properties) | _(optional)_ spacing properties like `top` or `bottom` are supported. | ## Styles diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/step-indicator/info.md b/packages/dnb-design-system-portal/src/docs/uilib/components/step-indicator/info.md index 468ca7be933..c09802226f8 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/step-indicator/info.md +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/step-indicator/info.md @@ -56,9 +56,9 @@ If you are able to provide the `data` to the Sidebar as well, it will use it dur The mode property is mandatory. It tells the component how it should behave. -- [`strict`](/uilib/components/step-indicator#strict-mode) -- [`loose`](/uilib/components/step-indicator#loose-mode) -- [`static`](/uilib/components/step-indicator#static-mode) +- [strict](/uilib/components/step-indicator#strict-mode) +- [loose](/uilib/components/step-indicator#loose-mode) +- [static](/uilib/components/step-indicator#static-mode) ### Strict mode diff --git a/packages/dnb-eufemia/src/components/breadcrumb/Breadcrumb.tsx b/packages/dnb-eufemia/src/components/breadcrumb/Breadcrumb.tsx index 2a636a357c5..ff0fe52bf38 100644 --- a/packages/dnb-eufemia/src/components/breadcrumb/Breadcrumb.tsx +++ b/packages/dnb-eufemia/src/components/breadcrumb/Breadcrumb.tsx @@ -4,7 +4,7 @@ import classnames from 'classnames' // Components import { createSkeletonClass } from '../skeleton/SkeletonHelper' import { createSpacingClasses } from '../space/SpacingHelper' -import Section from '../section/Section' +import Section, { SectionStyleTypes } from '../section/Section' import Button from '../button/Button' // Shared @@ -99,13 +99,13 @@ export interface BreadcrumbProps { * Use one of the Section component style types (style_type) * Default: transparent */ - styleType?: string + styleType?: SectionStyleTypes /** * Use one of the Section component style types (style_type) * Default: pistachio */ - collapsedStyleType?: string + collapsedStyleType?: SectionStyleTypes /** * Spacing around the breadcrumb diff --git a/packages/dnb-eufemia/src/components/dialog/__tests__/__snapshots__/Dialog.test.tsx.snap b/packages/dnb-eufemia/src/components/dialog/__tests__/__snapshots__/Dialog.test.tsx.snap index 211785f32e8..da1366eeb65 100644 --- a/packages/dnb-eufemia/src/components/dialog/__tests__/__snapshots__/Dialog.test.tsx.snap +++ b/packages/dnb-eufemia/src/components/dialog/__tests__/__snapshots__/Dialog.test.tsx.snap @@ -918,9 +918,7 @@ exports[`Dialog component snapshot should match component snapshot 1`] = ` className="dnb-dialog__navigation" >
, } } - spacing={null} style_type="white" >
, } } - spacing={null} style_type="white" >
-
+
{label && ( @@ -302,7 +302,7 @@ export default class FormRow extends React.PureComponent { {children}
)} - +
) diff --git a/packages/dnb-eufemia/src/components/form-row/__tests__/FormRow.test.js b/packages/dnb-eufemia/src/components/form-row/__tests__/FormRow.test.js index cf33ff02fc0..b876b56d03a 100644 --- a/packages/dnb-eufemia/src/components/form-row/__tests__/FormRow.test.js +++ b/packages/dnb-eufemia/src/components/form-row/__tests__/FormRow.test.js @@ -34,14 +34,16 @@ describe('FormRow component', () => { it('should have vertical direction class', () => { const Comp = mount() expect( - Comp.find('.dnb-form-row').hasClass('dnb-form-row--vertical') + Comp.find('.dnb-form-row').last().hasClass('dnb-form-row--vertical') ).toBe(true) }) it('should have correct indent class', () => { const Comp = mount() expect( - Comp.find('.dnb-form-row').hasClass('dnb-form-row__indent--large') + Comp.find('.dnb-form-row') + .last() + .hasClass('dnb-form-row__indent--large') ).toBe(true) }) diff --git a/packages/dnb-eufemia/src/components/form-row/__tests__/__snapshots__/FormRow.test.js.snap b/packages/dnb-eufemia/src/components/form-row/__tests__/__snapshots__/FormRow.test.js.snap index 7c4de9de0c4..83ab4fc5830 100644 --- a/packages/dnb-eufemia/src/components/form-row/__tests__/__snapshots__/FormRow.test.js.snap +++ b/packages/dnb-eufemia/src/components/form-row/__tests__/__snapshots__/FormRow.test.js.snap @@ -36,46 +36,53 @@ exports[`FormRow component have to match snapshot 1`] = `
-
- - - - - + + + - label - - -
- children + + label + + +
+ children +
-
+
diff --git a/packages/dnb-eufemia/src/components/form-set/__tests__/FormSet.test.js b/packages/dnb-eufemia/src/components/form-set/__tests__/FormSet.test.js index a384d37413f..063806b875b 100644 --- a/packages/dnb-eufemia/src/components/form-set/__tests__/FormSet.test.js +++ b/packages/dnb-eufemia/src/components/form-set/__tests__/FormSet.test.js @@ -41,7 +41,7 @@ describe('FormSet component', () => { ) expect( - Comp.find('.dnb-form-row').hasClass('dnb-form-row--vertical') + Comp.find('.dnb-form-row').last().hasClass('dnb-form-row--vertical') ).toBe(true) }) @@ -84,7 +84,9 @@ describe('FormSet component', () => { ) expect( - Comp.find('.dnb-form-row').hasClass('dnb-form-row__indent--large') + Comp.find('.dnb-form-row') + .last() + .hasClass('dnb-form-row__indent--large') ).toBe(true) }) diff --git a/packages/dnb-eufemia/src/components/global-status/__tests__/__snapshots__/GlobalStatus.test.js.snap b/packages/dnb-eufemia/src/components/global-status/__tests__/__snapshots__/GlobalStatus.test.js.snap index 515bb28e108..a33ce47ebcb 100644 --- a/packages/dnb-eufemia/src/components/global-status/__tests__/__snapshots__/GlobalStatus.test.js.snap +++ b/packages/dnb-eufemia/src/components/global-status/__tests__/__snapshots__/GlobalStatus.test.js.snap @@ -699,21 +699,14 @@ button.dnb-button::-moz-focus-inner { z-index: -8; } .dnb-section .dnb-section .dnb-section .dnb-section .dnb-section .dnb-section .dnb-section .dnb-section .dnb-section::after { z-index: -7; } + .dnb-section--spacing-x-small { + padding: var(--spacing-x-small) 0; } .dnb-section--spacing-small { - padding-top: var(--spacing-small); - padding-bottom: var(--spacing-small); } + padding: var(--spacing-small) 0; } .dnb-section--spacing-medium { - padding-top: var(--spacing-medium); - padding-bottom: var(--spacing-medium); } - .dnb-section--spacing, .dnb-section--spacing-default, .dnb-section--spacing-large { - padding-top: var(--spacing-large); - padding-bottom: var(--spacing-large); } - .dnb-section--spacing-x-large { - padding-top: var(--spacing-x-large); - padding-bottom: var(--spacing-xx-large); } - .dnb-section--spacing-xx-large { - padding-top: var(--spacing-xx-large); - padding-bottom: calc(var(--spacing-xx-large) + var(--spacing-small)); } + padding: var(--spacing-medium) 0; } + .dnb-section--spacing, .dnb-section--spacing-large { + padding: var(--spacing-large) 0; } .dnb-global-status { font-family: var(--font-family-default); @@ -921,11 +914,7 @@ exports[`GlobalStatus snapshot have to match component snapshot 1`] = ` className="dnb-global-status__content" >

, } } - spacing={null} style_type="white" >
-
- - - - - - -
- + Label + + +
- - - - - - - - - - - - + + - - + + + - - - - + - - - - - - - - - - + + - - + + + - - - - + + + +
-
+
diff --git a/packages/dnb-eufemia/src/components/section/Section.d.ts b/packages/dnb-eufemia/src/components/section/Section.d.ts deleted file mode 100644 index 3f03f052a81..00000000000 --- a/packages/dnb-eufemia/src/components/section/Section.d.ts +++ /dev/null @@ -1,85 +0,0 @@ -import * as React from 'react'; -export type SectionSpacing = string | boolean; -export type SectionSpace = - | string - | number - | boolean - | { - /** - * Use spacing values like: `small`, `1rem`, `1` or , `16px`. Will use `margin-top`. - */ - top?: string | number | boolean; - - /** - * Use spacing values like: `small`, `1rem`, `1` or , `16px`. will use `margin-right`. - */ - right?: string | number | boolean; - - /** - * Use spacing values like: `small`, `1rem`, `1` or , `16px`. will use `margin-bottom`. - */ - bottom?: string | number | boolean; - - /** - * Use spacing values like: `small`, `1rem`, `1` or , `16px`. will use `margin-left`. - */ - left?: string | number | boolean; - }; -export type SectionTop = string | number | boolean; -export type SectionRight = string | number | boolean; -export type SectionBottom = string | number | boolean; -export type SectionLeft = string | number | boolean; -export type SectionChildren = - | string - | ((...args: any[]) => any) - | React.ReactNode; - -export interface SectionProps extends React.HTMLProps { - /** - * To define the style of the visual helper. Use and `Style ID` from below. Defaults to `mint-green-12`. - */ - style_type?: string; - - /** - * Will add the default spacing around the wrapped content. Use `spacing-large`, `spacing-medium` or `spacing-small`. Defaults to `false`. If `true`, then `spacing-default` is used. Se the available sizes. - */ - spacing?: SectionSpacing; - - /** - * Define what HTML element should be used. Defaults to `
`. - */ - element?: string; - inner_ref?: React.RefObject; - - /** - * Has to be an object with either: `top`, `right`, `bottom` or `left`. Use spacing values like: `small`, `1rem`, `1` or , `16px`. - */ - space?: SectionSpace; - - /** - * Use spacing values like: `small`, `1rem`, `1` or , `16px`. Will use `margin-top`. - */ - top?: SectionTop; - - /** - * Use spacing values like: `small`, `1rem`, `1` or , `16px`. will use `margin-right`. - */ - right?: SectionRight; - - /** - * Use spacing values like: `small`, `1rem`, `1` or , `16px`. will use `margin-bottom`. - */ - bottom?: SectionBottom; - - /** - * Use spacing values like: `small`, `1rem`, `1` or , `16px`. will use `margin-left`. - */ - left?: SectionLeft; - class?: string; - className?: string; - children?: SectionChildren; -} -export default class Section extends React.Component { - static defaultProps: object; - render(): JSX.Element; -} diff --git a/packages/dnb-eufemia/src/components/section/Section.js b/packages/dnb-eufemia/src/components/section/Section.js deleted file mode 100644 index e5a5a1febd0..00000000000 --- a/packages/dnb-eufemia/src/components/section/Section.js +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Web Section Component - * - */ - -import React from 'react' -import PropTypes from 'prop-types' -import classnames from 'classnames' -import Context from '../../shared/Context' -import { - isTrue, - registerElement, - validateDOMAttributes, - processChildren, - extendPropsWithContext, -} from '../../shared/component-helper' -import { - spacingPropTypes, - createSpacingClasses, -} from '../space/SpacingHelper' - -export default class Section extends React.PureComponent { - static tagName = 'dnb-section' - static contextType = Context - - static propTypes = { - style_type: PropTypes.string, - spacing: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), - element: PropTypes.string, - inner_ref: PropTypes.object, - - ...spacingPropTypes, - - class: PropTypes.string, - className: PropTypes.string, - children: PropTypes.oneOfType([ - PropTypes.string, - PropTypes.func, - PropTypes.node, - ]), - } - - static defaultProps = { - style_type: null, - spacing: null, - element: 'section', - inner_ref: null, - class: null, - - className: null, - children: null, - } - - static enableWebComponent() { - registerElement(Section?.tagName, Section, Section.defaultProps) - } - - static getContent(props) { - if (props.text) return props.text - return processChildren(props) - } - - constructor(props) { - super(props) - this._ref = props.inner_ref || React.createRef() - } - - render() { - // use only the props from context, who are available here anyway - const props = extendPropsWithContext( - this.props, - Section.defaultProps, - this.context.FormRow, - this.context.Section - ) - - const { - element, - style_type, - spacing, - className, - class: _className, - - ...attributes - } = props - - const content = Section.getContent(this.props) - - const params = { - className: classnames( - 'dnb-section', - `dnb-section--${style_type || 'mint-green-12'}`, - (isTrue(spacing) || spacing) && - `dnb-section--spacing${ - !/true|false/.test(String(spacing)) ? '-' + spacing : '' - }`, - createSpacingClasses(props), - className, - _className - ), - ...attributes, - } - - // also used for code markup simulation - validateDOMAttributes(this.props, params) - - const Element = element || 'section' - - return ( - - {content} - - ) - } -} diff --git a/packages/dnb-eufemia/src/components/section/Section.tsx b/packages/dnb-eufemia/src/components/section/Section.tsx new file mode 100644 index 00000000000..bb8aaf4d456 --- /dev/null +++ b/packages/dnb-eufemia/src/components/section/Section.tsx @@ -0,0 +1,114 @@ +/** + * Web Section Component + * + */ + +import React from 'react' +import classnames from 'classnames' +import Context from '../../shared/Context' +import { + isTrue, + validateDOMAttributes, + extendPropsWithContext, +} from '../../shared/component-helper' +import { createSpacingClasses } from '../space/SpacingHelper' +import { DynamicElement, ISpacingProps } from '../../shared/interfaces' + +export type SectionStyleTypes = + | 'divider' + | 'white' + | 'transparent' + | 'lavender' + | 'pistachio' + | 'emerald-green' + | 'sea-green' + | 'fire-red' + | 'fire-red-8' + | 'sand-yellow' + | 'black-3' + | 'mint-green' + | 'mint-green-12' + +export type SectionSpacing = + | boolean + | 'x-small' + | 'small' + | 'medium' + | 'large' + +export type SectionProps = { + /** + * To define the style of the visual helper. Use and `Style ID` from below. Defaults to `mint-green-12`. + */ + style_type?: SectionStyleTypes + + /** + * Will add the default spacing around the wrapped content. Use `large`, `medium` or `small`. Defaults to `false`. If `true`, then `large` is used. Se the available sizes. + */ + spacing?: SectionSpacing + + /** + * Define what HTML element should be used. Defaults to `
`. + */ + element?: DynamicElement + + inner_ref?: React.RefObject + className?: string + children?: React.ReactNode +} & ISpacingProps & + React.HTMLProps + +const defaultProps = { + element: 'section', + style_type: null, + spacing: null, + inner_ref: null, + className: null, + children: null, +} + +export default function Section(localProps: SectionProps) { + const context = React.useContext(Context) + + // use only the props from context, who are available here anyway + const props = extendPropsWithContext( + localProps, + defaultProps, + context.FormRow, + context.Section + ) + + const { + element, + style_type, + spacing, + inner_ref, + + className, + children, + + ...attributes + } = props + + const params = { + className: classnames( + 'dnb-section', + `dnb-section--${style_type || 'mint-green-12'}`, + spacing && + `dnb-section--spacing-${isTrue(spacing) ? 'large' : spacing}`, + createSpacingClasses(props), + className + ), + ...(attributes as Record), + } + + const internalRef = React.useRef() + const elementRef = inner_ref || internalRef + params['ref'] = elementRef + + validateDOMAttributes(props, params) + + const Element = element || 'section' + + return {children} +} diff --git a/packages/dnb-eufemia/src/components/section/__tests__/Section.test.js b/packages/dnb-eufemia/src/components/section/__tests__/Section.test.js deleted file mode 100644 index af2beee0f23..00000000000 --- a/packages/dnb-eufemia/src/components/section/__tests__/Section.test.js +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Component Test - * - */ - -import React from 'react' -import { - mount, - fakeProps, - axeComponent, - toJson, - loadScss, -} from '../../../core/jest/jestSetup' -import Component from '../Section' - -const props = fakeProps(require.resolve('../Section'), { - optional: true, -}) -props.style = null -props.element = null -props.inner_ref = null -props.style_type = 'mint-green-12' - -describe('Section component', () => { - const Comp = mount() - - it('have to match snapshot', () => { - expect(toJson(Comp)).toMatchSnapshot() - }) - - it('should have correct styles', () => { - const Comp = mount() - expect( - Comp.find('section.dnb-section') - .first() - .hasClass('dnb-section--divider') - ).toBe(true) - }) - - it('should have correct spacing', () => { - const Comp = mount() - expect( - Comp.find('section.dnb-section') - .first() - .hasClass('dnb-section--spacing-large') - ).toBe(true) - }) - - it('should have a div as the element tag', () => { - const Comp = mount() - expect(Comp.find('div.dnb-section').exists()).toBe(true) - }) - - it('should validate with ARIA rules', async () => { - expect(await axeComponent(Comp)).toHaveNoViolations() - }) -}) - -describe('Section scss', () => { - it('have to match snapshot', () => { - const scss = loadScss(require.resolve('../style/dnb-section.scss')) - expect(scss).toMatchSnapshot() - }) - it('have to match default theme snapshot', () => { - const scss = loadScss( - require.resolve('../style/themes/dnb-section-theme-ui.scss') - ) - expect(scss).toMatchSnapshot() - }) -}) diff --git a/packages/dnb-eufemia/src/components/section/__tests__/Section.test.tsx b/packages/dnb-eufemia/src/components/section/__tests__/Section.test.tsx new file mode 100644 index 00000000000..695f070a7c6 --- /dev/null +++ b/packages/dnb-eufemia/src/components/section/__tests__/Section.test.tsx @@ -0,0 +1,84 @@ +/** + * Component Test + * + */ + +import React from 'react' +import { render } from '@testing-library/react' +import { + mount, + fakeProps, + axeComponent, + toJson, + loadScss, +} from '../../../core/jest/jestSetup' +import Section from '../Section' + +const props = fakeProps(require.resolve('../Section'), { + all: true, +}) +props.style = null +props.element = null +props.inner_ref = null +props.style_type = 'mint-green-12' + +describe('Section component', () => { + it('have to match snapshot', () => { + const Comp = mount(
) + expect(toJson(Comp)).toMatchSnapshot() + }) + + it('should have correct styles', () => { + render(
) + expect( + document + .querySelector('section.dnb-section') + .classList.contains('dnb-section--divider') + ).toBe(true) + }) + + it('should have correct spacing', () => { + const hasSpacing = () => + Array.from(document.querySelector('section.dnb-section').classList) + .filter((className) => className.includes('dnb-section--spacing')) + .join('') + + const { rerender } = render(
) + expect(hasSpacing()).toBe('') + + rerender(
) + expect(hasSpacing()).toBe('dnb-section--spacing-large') + + rerender(
) + expect(hasSpacing()).toBe('dnb-section--spacing-medium') + + rerender(
) + expect(hasSpacing()).toBe('dnb-section--spacing-small') + + rerender(
) + expect(hasSpacing()).toBe('dnb-section--spacing-large') + }) + + it('should have a div as the element tag', () => { + render(
) + expect(document.querySelector('div.dnb-section')).toBeTruthy() + }) + + it('should validate with ARIA rules', async () => { + const Component = render(
) + expect(await axeComponent(Component)).toHaveNoViolations() + }) +}) + +describe('Section scss', () => { + it('have to match snapshot', () => { + const scss = loadScss(require.resolve('../style/dnb-section.scss')) + expect(scss).toMatchSnapshot() + }) + it('have to match default theme snapshot', () => { + const scss = loadScss( + require.resolve('../style/themes/dnb-section-theme-ui.scss') + ) + expect(scss).toMatchSnapshot() + }) +}) diff --git a/packages/dnb-eufemia/src/components/section/__tests__/__snapshots__/Section.test.js.snap b/packages/dnb-eufemia/src/components/section/__tests__/__snapshots__/Section.test.tsx.snap similarity index 92% rename from packages/dnb-eufemia/src/components/section/__tests__/__snapshots__/Section.test.js.snap rename to packages/dnb-eufemia/src/components/section/__tests__/__snapshots__/Section.test.tsx.snap index cd9dd8f5194..c1a34472d9d 100644 --- a/packages/dnb-eufemia/src/components/section/__tests__/__snapshots__/Section.test.js.snap +++ b/packages/dnb-eufemia/src/components/section/__tests__/__snapshots__/Section.test.tsx.snap @@ -2,19 +2,20 @@ exports[`Section component have to match snapshot 1`] = `
- children -
+ className="dnb-section dnb-section--mint-green-12" + />
`; @@ -270,20 +271,13 @@ exports[`Section scss have to match snapshot 1`] = ` z-index: -8; } .dnb-section .dnb-section .dnb-section .dnb-section .dnb-section .dnb-section .dnb-section .dnb-section .dnb-section::after { z-index: -7; } + .dnb-section--spacing-x-small { + padding: var(--spacing-x-small) 0; } .dnb-section--spacing-small { - padding-top: var(--spacing-small); - padding-bottom: var(--spacing-small); } + padding: var(--spacing-small) 0; } .dnb-section--spacing-medium { - padding-top: var(--spacing-medium); - padding-bottom: var(--spacing-medium); } - .dnb-section--spacing, .dnb-section--spacing-default, .dnb-section--spacing-large { - padding-top: var(--spacing-large); - padding-bottom: var(--spacing-large); } - .dnb-section--spacing-x-large { - padding-top: var(--spacing-x-large); - padding-bottom: var(--spacing-xx-large); } - .dnb-section--spacing-xx-large { - padding-top: var(--spacing-xx-large); - padding-bottom: calc(var(--spacing-xx-large) + var(--spacing-small)); } + padding: var(--spacing-medium) 0; } + .dnb-section--spacing, .dnb-section--spacing-large { + padding: var(--spacing-large) 0; } " `; diff --git a/packages/dnb-eufemia/src/components/section/__tests__/__snapshots__/section-screenshot-test-js-section-screenshot-have-to-match-default-section-1-b7c64.snap.png b/packages/dnb-eufemia/src/components/section/__tests__/__snapshots__/section-screenshot-test-js-section-screenshot-have-to-match-default-section-1-b7c64.snap.png index c148cefd612..5c8806d1275 100644 Binary files a/packages/dnb-eufemia/src/components/section/__tests__/__snapshots__/section-screenshot-test-js-section-screenshot-have-to-match-default-section-1-b7c64.snap.png and b/packages/dnb-eufemia/src/components/section/__tests__/__snapshots__/section-screenshot-test-js-section-screenshot-have-to-match-default-section-1-b7c64.snap.png differ diff --git a/packages/dnb-eufemia/src/components/section/__tests__/__snapshots__/section-screenshot-test-js-section-screenshot-have-to-match-divider-section-1-09379.snap.png b/packages/dnb-eufemia/src/components/section/__tests__/__snapshots__/section-screenshot-test-js-section-screenshot-have-to-match-divider-section-1-09379.snap.png index bda14298eb4..63a59c0e42b 100644 Binary files a/packages/dnb-eufemia/src/components/section/__tests__/__snapshots__/section-screenshot-test-js-section-screenshot-have-to-match-divider-section-1-09379.snap.png and b/packages/dnb-eufemia/src/components/section/__tests__/__snapshots__/section-screenshot-test-js-section-screenshot-have-to-match-divider-section-1-09379.snap.png differ diff --git a/packages/dnb-eufemia/src/components/section/__tests__/__snapshots__/section-screenshot-test-js-section-screenshot-have-to-match-emerald-green-section-1-a7bec.snap.png b/packages/dnb-eufemia/src/components/section/__tests__/__snapshots__/section-screenshot-test-js-section-screenshot-have-to-match-emerald-green-section-1-a7bec.snap.png index f7a2b29fddc..8c1aa454d34 100644 Binary files a/packages/dnb-eufemia/src/components/section/__tests__/__snapshots__/section-screenshot-test-js-section-screenshot-have-to-match-emerald-green-section-1-a7bec.snap.png and b/packages/dnb-eufemia/src/components/section/__tests__/__snapshots__/section-screenshot-test-js-section-screenshot-have-to-match-emerald-green-section-1-a7bec.snap.png differ diff --git a/packages/dnb-eufemia/src/components/section/__tests__/__snapshots__/section-screenshot-test-js-section-screenshot-have-to-match-lavender-section-1-bcea6.snap.png b/packages/dnb-eufemia/src/components/section/__tests__/__snapshots__/section-screenshot-test-js-section-screenshot-have-to-match-lavender-section-1-bcea6.snap.png index ae7b7c52774..5038e77e23e 100644 Binary files a/packages/dnb-eufemia/src/components/section/__tests__/__snapshots__/section-screenshot-test-js-section-screenshot-have-to-match-lavender-section-1-bcea6.snap.png and b/packages/dnb-eufemia/src/components/section/__tests__/__snapshots__/section-screenshot-test-js-section-screenshot-have-to-match-lavender-section-1-bcea6.snap.png differ diff --git a/packages/dnb-eufemia/src/components/section/__tests__/__snapshots__/section-screenshot-test-js-section-screenshot-have-to-match-mint-green-section-1-e9553.snap.png b/packages/dnb-eufemia/src/components/section/__tests__/__snapshots__/section-screenshot-test-js-section-screenshot-have-to-match-mint-green-section-1-e9553.snap.png index a51e50c84bd..d70cfb29da9 100644 Binary files a/packages/dnb-eufemia/src/components/section/__tests__/__snapshots__/section-screenshot-test-js-section-screenshot-have-to-match-mint-green-section-1-e9553.snap.png and b/packages/dnb-eufemia/src/components/section/__tests__/__snapshots__/section-screenshot-test-js-section-screenshot-have-to-match-mint-green-section-1-e9553.snap.png differ diff --git a/packages/dnb-eufemia/src/components/section/style/_section.scss b/packages/dnb-eufemia/src/components/section/style/_section.scss index 7c4f0673bcc..dc45ce7d2a3 100644 --- a/packages/dnb-eufemia/src/components/section/style/_section.scss +++ b/packages/dnb-eufemia/src/components/section/style/_section.scss @@ -3,7 +3,7 @@ * */ -@mixin SectionStyle() { +.dnb-section { position: relative; // flow-root allows content to have margin top and bottom @@ -51,37 +51,20 @@ z-index: -7; } + &--spacing-x-small { + padding: var(--spacing-x-small) 0; + } + &--spacing-small { - padding-top: var(--spacing-small); - padding-bottom: var(--spacing-small); + padding: var(--spacing-small) 0; } &--spacing-medium { - padding-top: var(--spacing-medium); - padding-bottom: var(--spacing-medium); + padding: var(--spacing-medium) 0; } - // spacing-default &--spacing, - &--spacing-default, &--spacing-large { - padding-top: var(--spacing-large); - padding-bottom: var(--spacing-large); - } - - &--spacing-x-large { - padding-top: var(--spacing-x-large); - // larger than top - padding-bottom: var(--spacing-xx-large); + padding: var(--spacing-large) 0; } - - &--spacing-xx-large { - padding-top: var(--spacing-xx-large); - // larger than top - padding-bottom: calc(var(--spacing-xx-large) + var(--spacing-small)); - } -} - -.dnb-section { - @include SectionStyle(); } diff --git a/packages/dnb-eufemia/src/components/section/style/themes/dnb-section-theme-ui.scss b/packages/dnb-eufemia/src/components/section/style/themes/dnb-section-theme-ui.scss index 97fa379d367..9ccec7b3d6d 100644 --- a/packages/dnb-eufemia/src/components/section/style/themes/dnb-section-theme-ui.scss +++ b/packages/dnb-eufemia/src/components/section/style/themes/dnb-section-theme-ui.scss @@ -5,7 +5,7 @@ @import '../../../../style/elements/_anchor-mixins.scss'; -@mixin SectionTheme() { +.dnb-section { &--divider { color: var(--color-black-80); &::after { @@ -136,7 +136,3 @@ } } } - -.dnb-section { - @include SectionTheme(); -} diff --git a/packages/dnb-eufemia/src/components/toggle-button/__tests__/__snapshots__/ToggleButton.test.js.snap b/packages/dnb-eufemia/src/components/toggle-button/__tests__/__snapshots__/ToggleButton.test.js.snap index b183a09bc0d..b894e7b23f2 100644 --- a/packages/dnb-eufemia/src/components/toggle-button/__tests__/__snapshots__/ToggleButton.test.js.snap +++ b/packages/dnb-eufemia/src/components/toggle-button/__tests__/__snapshots__/ToggleButton.test.js.snap @@ -560,235 +560,308 @@ exports[`ToggleButton group component have to match group snapshot 1`] = `
-
- - - - - - Label - -
- - + + + + Label + + +
- + - - - + - - - + + variant={null} + width_element={null} + width_selector={null} + /> + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + ‌ + + + ToggleButton 2 + + + + + + - - + + - +
-
+
diff --git a/packages/dnb-eufemia/src/shared/Context.tsx b/packages/dnb-eufemia/src/shared/Context.tsx index 8f877fce90a..f549ed4c13f 100644 --- a/packages/dnb-eufemia/src/shared/Context.tsx +++ b/packages/dnb-eufemia/src/shared/Context.tsx @@ -25,6 +25,7 @@ import type { VisuallyHiddenProps } from '../components/visually-hidden/Visually import type { DrawerProps } from '../components/drawer/types' import type { DialogProps } from '../components/dialog/types' import type { TooltipProps } from '../components/tooltip/types' +import type { SectionProps } from '../components/section/Section' // All TypeScript based Eufemia elements import type { AnchorProps } from '../elements/Anchor' @@ -50,6 +51,7 @@ export type ContextProps = { Drawer?: Partial Dialog?: Partial Tooltip?: Partial + Section?: Partial ScrollView?: Partial // -- TODO: Not converted yet --