diff --git a/packages/eds-core-react/src/components/Banner/Banner.stories.tsx b/packages/eds-core-react/src/components/Banner/Banner.stories.tsx index f9793f9d61..eb9a0c7fe3 100644 --- a/packages/eds-core-react/src/components/Banner/Banner.stories.tsx +++ b/packages/eds-core-react/src/components/Banner/Banner.stories.tsx @@ -28,11 +28,11 @@ export default { }, } as ComponentMeta -export const Introduction: Story = () => { +export const Introduction: Story = (args) => { // Note: This example is not interactive, as Storybook // doesn't yet support to manipulate subcomponents via Storybook Args return ( - + This tag is not being preserved yet. Click start preservation to enable writing preservation records. diff --git a/packages/eds-core-react/src/components/Banner/Banner.tsx b/packages/eds-core-react/src/components/Banner/Banner.tsx index b5c0b64ff0..179d6bdff7 100644 --- a/packages/eds-core-react/src/components/Banner/Banner.tsx +++ b/packages/eds-core-react/src/components/Banner/Banner.tsx @@ -7,12 +7,14 @@ import { } from 'react' import styled, { css, ThemeProvider } from 'styled-components' import { spacingsTemplate, useToken } from '@equinor/eds-utils' +import { Paper } from '../Paper' +import type { Elevations } from '@equinor/eds-tokens' import { enabled as bannerToken } from './Banner.tokens' import { Divider } from '../Divider' import { BannerIcon } from './BannerIcon' import { useEds } from '../EdsProvider' -const StyledBanner = styled.div`` +type AvailableElevations = keyof Pick type ContentProps = { hasIcon: boolean @@ -35,11 +37,12 @@ const NonMarginDivider = styled(Divider)` ` export type BannerProps = { + elevation?: AvailableElevations children: ReactNode } & HTMLAttributes export const Banner = forwardRef(function Banner( - { children, className, ...rest }, + { children, className, elevation = 'none', ...rest }, ref, ) { const childrenWhereBannerIcon: boolean[] = ReactChildren.map( @@ -60,10 +63,15 @@ export const Banner = forwardRef(function Banner( return ( - + {children} - + ) }) diff --git a/packages/eds-core-react/src/components/Banner/__snapshots__/Banner.test.tsx.snap b/packages/eds-core-react/src/components/Banner/__snapshots__/Banner.test.tsx.snap index e63fe67338..45a040b6c4 100644 --- a/packages/eds-core-react/src/components/Banner/__snapshots__/Banner.test.tsx.snap +++ b/packages/eds-core-react/src/components/Banner/__snapshots__/Banner.test.tsx.snap @@ -2,7 +2,12 @@ exports[`Banner Matches snapshot 1`] = ` - .c3 { + .c0 { + background: var(--eds_ui_background__default,rgba(255,255,255,1)); + box-shadow: 0 0 1px rgba(0,0,0,0.14); +} + +.c4 { border: none; background-color: var(--eds_ui_background__light,rgba(247,247,247,1)); margin-top: 16px; @@ -10,7 +15,7 @@ exports[`Banner Matches snapshot 1`] = ` height: 1px; } -.c1 { +.c2 { display: -webkit-inline-box; display: -webkit-inline-flex; display: -ms-inline-flexbox; @@ -33,7 +38,7 @@ exports[`Banner Matches snapshot 1`] = ` margin-right: 16px; } -.c0 { +.c1 { padding-left: 16px; padding-top: 16px; padding-right: 16px; @@ -47,12 +52,12 @@ exports[`Banner Matches snapshot 1`] = ` background-color: var(--eds_ui_background__default,rgba(255,255,255,1)); } -.c4 { +.c5 { margin: 0; height: 2px; } -.c2 { +.c3 { margin: 0; color: rgba(61,61,61,1); font-family: Equinor; @@ -63,14 +68,15 @@ exports[`Banner Matches snapshot 1`] = ` }

Banner message


diff --git a/packages/eds-core-react/src/components/Card/Card.tsx b/packages/eds-core-react/src/components/Card/Card.tsx index 6ac54ba91c..48d781c9e9 100644 --- a/packages/eds-core-react/src/components/Card/Card.tsx +++ b/packages/eds-core-react/src/components/Card/Card.tsx @@ -1,10 +1,14 @@ import { forwardRef, HTMLAttributes } from 'react' import styled from 'styled-components' +import { Paper } from '../Paper' +import type { Elevations } from '@equinor/eds-tokens' import * as tokens from './Card.tokens' import { bordersTemplate } from '@equinor/eds-utils' const { primary } = tokens +type AvailableElevations = keyof Pick + type StyledCardProps = { background: string cursor: string @@ -13,9 +17,11 @@ type StyledCardProps = { export type CardProps = { /** Variant */ variant?: 'default' | 'info' | 'warning' | 'danger' + /** Elevation */ + elevation?: AvailableElevations } & HTMLAttributes -const StyledCard = styled.div` +const StyledCard = styled(Paper)` width: 100%; position: relative; background-color: ${({ background }) => background}; @@ -28,7 +34,7 @@ const StyledCard = styled.div` ` export const Card = forwardRef(function Card( - { children, variant = 'default', onClick, ...rest }, + { children, variant = 'default', elevation = 'none', onClick, ...rest }, ref, ) { const cursor = onClick ? 'pointer' : 'default' @@ -45,7 +51,7 @@ export const Card = forwardRef(function Card( } return ( - + {children} ) diff --git a/packages/eds-core-react/src/components/Card/__snapshots__/Card.test.tsx.snap b/packages/eds-core-react/src/components/Card/__snapshots__/Card.test.tsx.snap index 4defe58d60..8f26924a37 100644 --- a/packages/eds-core-react/src/components/Card/__snapshots__/Card.test.tsx.snap +++ b/packages/eds-core-react/src/components/Card/__snapshots__/Card.test.tsx.snap @@ -2,7 +2,7 @@ exports[`Card Matches snapshot 1`] = ` - .c4 { + .c5 { margin: 0; color: rgba(61,61,61,1); font-family: Equinor; @@ -16,7 +16,7 @@ exports[`Card Matches snapshot 1`] = ` text-align: left; } -.c5 { +.c6 { margin: 0; color: rgba(61,61,61,1); font-family: Equinor; @@ -27,6 +27,11 @@ exports[`Card Matches snapshot 1`] = ` } .c0 { + background: var(--eds_ui_background__default,rgba(255,255,255,1)); + box-shadow: 0 0 1px rgba(0,0,0,0.14); +} + +.c1 { width: 100%; position: relative; background-color: var(--eds_ui_background__default,rgba(255,255,255,1)); @@ -43,7 +48,7 @@ exports[`Card Matches snapshot 1`] = ` border-radius: 4px; } -.c1 { +.c2 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; @@ -51,21 +56,21 @@ exports[`Card Matches snapshot 1`] = ` width: auto; } -.c1 > * { +.c2 > * { width: 100%; } -.c1:first-child img { +.c2:first-child img { border-top-right-radius: 4px; border-top-left-radius: 4px; } -.c1:last-child img { +.c2:last-child img { border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; } -.c2 { +.c3 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; @@ -81,19 +86,19 @@ exports[`Card Matches snapshot 1`] = ` padding: 0 16px 0 16px; } -.c2 > :not(:first-child) { +.c3 > :not(:first-child) { margin-left: 16px; } -.c2:first-child { +.c3:first-child { padding-top: 16px; } -.c2:last-child { +.c3:last-child { padding-bottom: 16px; } -.c3 { +.c4 { display: grid; -webkit-box-flex: 2; -webkit-flex-grow: 2; @@ -103,11 +108,12 @@ exports[`Card Matches snapshot 1`] = ` }
cat
Another interactive example

Unfortunately you cannot control children in storybook yet

Leading images are full width, and go straight to the top - ignoring spacings

diff --git a/packages/eds-core-react/src/components/Dialog/__snapshots__/Dialog.test.tsx.snap b/packages/eds-core-react/src/components/Dialog/__snapshots__/Dialog.test.tsx.snap index f64f1641fb..ad07683cb6 100644 --- a/packages/eds-core-react/src/components/Dialog/__snapshots__/Dialog.test.tsx.snap +++ b/packages/eds-core-react/src/components/Dialog/__snapshots__/Dialog.test.tsx.snap @@ -2,8 +2,6 @@ exports[`Dialog Matches snapshot 1`] = ` .c0 { - min-width: 96px; - max-width: calc(100% - 32px); background: var(--eds_ui_background__default,rgba(255,255,255,1)); box-shadow: 0 11px 15px rgba(0,0,0,0.2),0 9px 46px rgba(0,0,0,0.12),0 24px 38px rgba(0,0,0,0.14); } diff --git a/packages/eds-core-react/src/components/Paper/Paper.tokens.tsx b/packages/eds-core-react/src/components/Paper/Paper.tokens.tsx index 6d3cb9c3ba..ae4db3d3c3 100644 --- a/packages/eds-core-react/src/components/Paper/Paper.tokens.tsx +++ b/packages/eds-core-react/src/components/Paper/Paper.tokens.tsx @@ -14,7 +14,5 @@ export type ElevationTypes = keyof Elevations export { elevation } export const paper: ComponentToken = { - maxWidth: 'calc(100% - 32px)', - minWidth: '96px', background, } diff --git a/packages/eds-core-react/src/components/Paper/Paper.tsx b/packages/eds-core-react/src/components/Paper/Paper.tsx index b7fa6e7ddd..f8f4f965b5 100644 --- a/packages/eds-core-react/src/components/Paper/Paper.tsx +++ b/packages/eds-core-react/src/components/Paper/Paper.tsx @@ -11,8 +11,6 @@ type StyledProps = { } const StyledPaper = styled.div` - min-width: ${tokens.minWidth}; - max-width: ${tokens.maxWidth}; background: ${tokens.background}; box-shadow: ${({ elevation }) => elevation}; ` diff --git a/packages/eds-core-react/src/components/Popover/__snapshots__/Popover.test.tsx.snap b/packages/eds-core-react/src/components/Popover/__snapshots__/Popover.test.tsx.snap index 377cf1dd71..cc2de8a8aa 100644 --- a/packages/eds-core-react/src/components/Popover/__snapshots__/Popover.test.tsx.snap +++ b/packages/eds-core-react/src/components/Popover/__snapshots__/Popover.test.tsx.snap @@ -2,8 +2,6 @@ exports[`Popover Matches snapshot 1`] = ` .c0 { - min-width: 96px; - max-width: calc(100% - 32px); background: var(--eds_ui_background__default,rgba(255,255,255,1)); box-shadow: 0 1px 10px rgba(0,0,0,0.2),0 4px 5px rgba(0,0,0,0.12),0 2px 4px rgba(0,0,0,0.14); } diff --git a/packages/eds-core-react/src/components/Snackbar/__snapshots__/Snackbar.test.tsx.snap b/packages/eds-core-react/src/components/Snackbar/__snapshots__/Snackbar.test.tsx.snap index 4055fd5a47..082ad22ea6 100644 --- a/packages/eds-core-react/src/components/Snackbar/__snapshots__/Snackbar.test.tsx.snap +++ b/packages/eds-core-react/src/components/Snackbar/__snapshots__/Snackbar.test.tsx.snap @@ -2,8 +2,6 @@ exports[`Snackbar Matches snapshot 1`] = ` .c0 { - min-width: 96px; - max-width: calc(100% - 32px); background: var(--eds_ui_background__default,rgba(255,255,255,1)); box-shadow: 0 1px 10px rgba(0,0,0,0.2),0 4px 5px rgba(0,0,0,0.12),0 2px 4px rgba(0,0,0,0.14); } diff --git a/packages/eds-core-react/src/components/TopBar/TopBar.stories.tsx b/packages/eds-core-react/src/components/TopBar/TopBar.stories.tsx index 12dd6de627..d2feb1d40d 100644 --- a/packages/eds-core-react/src/components/TopBar/TopBar.stories.tsx +++ b/packages/eds-core-react/src/components/TopBar/TopBar.stories.tsx @@ -38,12 +38,12 @@ const icons = { Icon.add(icons) const Wrapper = styled.div.attrs({ tabIndex: 0 })` - height: 100vh; + height: 65vh; overflow: auto; ` const BodyWrapper = styled.div` - height: 1500px; + height: 1000px; background: #ebebeb; display: flex; flex-direction: column; diff --git a/packages/eds-core-react/src/components/TopBar/TopBar.tsx b/packages/eds-core-react/src/components/TopBar/TopBar.tsx index 81fadf46bd..e98613ea8a 100644 --- a/packages/eds-core-react/src/components/TopBar/TopBar.tsx +++ b/packages/eds-core-react/src/components/TopBar/TopBar.tsx @@ -6,12 +6,18 @@ import { bordersTemplate, useToken, } from '@equinor/eds-utils' +import { Paper } from '../Paper' +import type { Elevations } from '@equinor/eds-tokens' import { topbar as topbarToken } from './TopBar.tokens' import { useEds } from '../EdsProvider' -export type TopbarProps = HTMLAttributes +type AvailableElevations = keyof Pick -const StyledTopBar = styled.header(({ theme }) => { +export type TopbarProps = { + elevation?: AvailableElevations +} & HTMLAttributes + +const StyledTopBar = styled(Paper)(({ theme }) => { return css` height: ${theme.height}; top: 0; @@ -30,15 +36,19 @@ const StyledTopBar = styled.header(({ theme }) => { ` }) -export const TopBar = forwardRef(function TopBar( - { children, ...props }, +export const TopBar = forwardRef(function TopBar( + { children, elevation = 'none', ...props }, ref, ) { const { density } = useEds() const token = useToken({ density }, topbarToken) + const rest = { + ...props, + ref, + } return ( - + {children}