Skip to content

Commit

Permalink
fix(Icon): enhance alignment when used in paragraphs (#2368)
Browse files Browse the repository at this point in the history
* fix(Icon): enhance alignment when used in paragraphs

* Correct demo example paragraph usage

* Update snapshots

* Update visual snapshots
  • Loading branch information
tujoworker authored and langz committed May 31, 2023
1 parent 160e1e5 commit 11c1945
Show file tree
Hide file tree
Showing 33 changed files with 296 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import * as PrimaryIconsMedium from '@dnb/eufemia/src/icons/dnb/primary_icons_me
import * as SecondaryIconsMedium from '@dnb/eufemia/src/icons/dnb/secondary_icons_medium'
import { getListOfIcons } from '../../../../shared/parts/icons/ListAllIcons'

import { Icon, P, IconPrimary, Button } from '@dnb/eufemia/src'
import { Icon, P, H2, IconPrimary, Button } from '@dnb/eufemia/src'
import styled from '@emotion/styled'

export const IconDefault = () => (
<ComponentBox
Expand Down Expand Up @@ -78,6 +79,47 @@ export const IconMedium = () => {
)
}

export const IconAlignment = () => {
if (!globalThis.IS_TEST) {
return null
}

return (
<ComponentBox
data-visual-test="icon-alignment"
scope={{ Bell, BellMedium }}
>
{() => {
const ColoredP = styled(P)`
display: inline-block;
background-color: yellowgreen;
`
const ColoredH = styled(H2)`
display: inline-block;
margin: 0 0 0.5rem 0 !important;
background-color: yellowgreen;
`
const ColoredIcon = styled(Icon)`
background-color: yellow;
`
return (
<div className="dnb-core-style">
<ColoredH>
<ColoredIcon icon={Bell} />
Text
</ColoredH>
<br />
<ColoredP>
<ColoredIcon icon={Bell} />
Text
</ColoredP>
</div>
)
}}
</ComponentBox>
)
}

export const AllPrimaryIcons = () => {
if (!globalThis.IS_TEST) {
return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ draft: true
---

import {
IconAlignment,
IconMedium,
AllIconsTest,
} from 'Docs/uilib/components/icon/Examples'

<IconAlignment />

<IconMedium />

<AllIconsTest />
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ const MainForm = () => {

<Attachment>
<Attachment.FileRow>
<Icon icon={AttachmentIcon} aria-hidden />
{' filename_01.jpg'}
<Icon icon={AttachmentIcon} />
filename_01.jpg
</Attachment.FileRow>
<Button
text="Delete"
Expand Down Expand Up @@ -304,7 +304,7 @@ const Ingress = (props) => (
)

// Attachment area
const Attachment = styled(Space)`
const Attachment = styled(P)`
.dnb-button {
margin-left: 1rem;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,9 @@ exports[`Accordion scss have to match snapshot 1`] = `
width: 1em;
height: 1em;
}
.dnb-icon img,
.dnb-icon svg {
.dnb-icon img, .dnb-core-style .dnb-icon img,
.dnb-icon svg,
.dnb-core-style .dnb-icon svg {
width: inherit;
height: inherit;
shape-rendering: geometricprecision;
Expand Down Expand Up @@ -366,9 +367,12 @@ exports[`Accordion scss have to match snapshot 1`] = `
align-items: center;
justify-content: center;
}
h1 .dnb-icon, h2 .dnb-icon, h3 .dnb-icon, h4 .dnb-icon, h5 .dnb-icon, h6 .dnb-icon {
h1 > .dnb-icon, h2 > .dnb-icon, h3 > .dnb-icon, h4 > .dnb-icon, h5 > .dnb-icon, h6 > .dnb-icon {
vertical-align: middle;
}
p > .dnb-icon {
vertical-align: inherit;
}
.dnb-icon.dnb-skeleton {
color: var(--skeleton-color) !important;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1598,8 +1598,9 @@ exports[`Autocomplete scss have to match snapshot 1`] = `
width: 1em;
height: 1em;
}
.dnb-icon img,
.dnb-icon svg {
.dnb-icon img, .dnb-core-style .dnb-icon img,
.dnb-icon svg,
.dnb-core-style .dnb-icon svg {
width: inherit;
height: inherit;
shape-rendering: geometricprecision;
Expand Down Expand Up @@ -1647,9 +1648,12 @@ exports[`Autocomplete scss have to match snapshot 1`] = `
align-items: center;
justify-content: center;
}
h1 .dnb-icon, h2 .dnb-icon, h3 .dnb-icon, h4 .dnb-icon, h5 .dnb-icon, h6 .dnb-icon {
h1 > .dnb-icon, h2 > .dnb-icon, h3 > .dnb-icon, h4 > .dnb-icon, h5 > .dnb-icon, h6 > .dnb-icon {
vertical-align: middle;
}
p > .dnb-icon {
vertical-align: inherit;
}
.dnb-icon.dnb-skeleton {
color: var(--skeleton-color) !important;
}
Expand Down Expand Up @@ -2136,8 +2140,9 @@ button.dnb-button::-moz-focus-inner {
width: 1em;
height: 1em;
}
.dnb-icon img,
.dnb-icon svg {
.dnb-icon img, .dnb-core-style .dnb-icon img,
.dnb-icon svg,
.dnb-core-style .dnb-icon svg {
width: inherit;
height: inherit;
shape-rendering: geometricprecision;
Expand Down Expand Up @@ -2185,9 +2190,12 @@ button.dnb-button::-moz-focus-inner {
align-items: center;
justify-content: center;
}
h1 .dnb-icon, h2 .dnb-icon, h3 .dnb-icon, h4 .dnb-icon, h5 .dnb-icon, h6 .dnb-icon {
h1 > .dnb-icon, h2 > .dnb-icon, h3 > .dnb-icon, h4 > .dnb-icon, h5 > .dnb-icon, h6 > .dnb-icon {
vertical-align: middle;
}
p > .dnb-icon {
vertical-align: inherit;
}
.dnb-icon.dnb-skeleton {
color: var(--skeleton-color) !important;
}
Expand Down Expand Up @@ -2822,8 +2830,9 @@ html[data-visual-test] .dnb-input__input {
width: 1em;
height: 1em;
}
.dnb-icon img,
.dnb-icon svg {
.dnb-icon img, .dnb-core-style .dnb-icon img,
.dnb-icon svg,
.dnb-core-style .dnb-icon svg {
width: inherit;
height: inherit;
shape-rendering: geometricprecision;
Expand Down Expand Up @@ -2871,9 +2880,12 @@ html[data-visual-test] .dnb-input__input {
align-items: center;
justify-content: center;
}
h1 .dnb-icon, h2 .dnb-icon, h3 .dnb-icon, h4 .dnb-icon, h5 .dnb-icon, h6 .dnb-icon {
h1 > .dnb-icon, h2 > .dnb-icon, h3 > .dnb-icon, h4 > .dnb-icon, h5 > .dnb-icon, h6 > .dnb-icon {
vertical-align: middle;
}
p > .dnb-icon {
vertical-align: inherit;
}
.dnb-icon.dnb-skeleton {
color: var(--skeleton-color) !important;
}
Expand Down Expand Up @@ -2911,8 +2923,9 @@ h1 .dnb-icon, h2 .dnb-icon, h3 .dnb-icon, h4 .dnb-icon, h5 .dnb-icon, h6 .dnb-ic
width: 1em;
height: 1em;
}
.dnb-icon img,
.dnb-icon svg {
.dnb-icon img, .dnb-core-style .dnb-icon img,
.dnb-icon svg,
.dnb-core-style .dnb-icon svg {
width: inherit;
height: inherit;
shape-rendering: geometricprecision;
Expand Down Expand Up @@ -2960,9 +2973,12 @@ h1 .dnb-icon, h2 .dnb-icon, h3 .dnb-icon, h4 .dnb-icon, h5 .dnb-icon, h6 .dnb-ic
align-items: center;
justify-content: center;
}
h1 .dnb-icon, h2 .dnb-icon, h3 .dnb-icon, h4 .dnb-icon, h5 .dnb-icon, h6 .dnb-icon {
h1 > .dnb-icon, h2 > .dnb-icon, h3 > .dnb-icon, h4 > .dnb-icon, h5 > .dnb-icon, h6 > .dnb-icon {
vertical-align: middle;
}
p > .dnb-icon {
vertical-align: inherit;
}
.dnb-icon.dnb-skeleton {
color: var(--skeleton-color) !important;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ exports[`Breadcrumb scss have to match snapshot 1`] = `
width: 1em;
height: 1em;
}
.dnb-icon img,
.dnb-icon svg {
.dnb-icon img, .dnb-core-style .dnb-icon img,
.dnb-icon svg,
.dnb-core-style .dnb-icon svg {
width: inherit;
height: inherit;
shape-rendering: geometricprecision;
Expand Down Expand Up @@ -87,9 +88,12 @@ exports[`Breadcrumb scss have to match snapshot 1`] = `
align-items: center;
justify-content: center;
}
h1 .dnb-icon, h2 .dnb-icon, h3 .dnb-icon, h4 .dnb-icon, h5 .dnb-icon, h6 .dnb-icon {
h1 > .dnb-icon, h2 > .dnb-icon, h3 > .dnb-icon, h4 > .dnb-icon, h5 > .dnb-icon, h6 > .dnb-icon {
vertical-align: middle;
}
p > .dnb-icon {
vertical-align: inherit;
}
.dnb-icon.dnb-skeleton {
color: var(--skeleton-color) !important;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1426,8 +1426,9 @@ exports[`Button scss have to match snapshot 1`] = `
width: 1em;
height: 1em;
}
.dnb-icon img,
.dnb-icon svg {
.dnb-icon img, .dnb-core-style .dnb-icon img,
.dnb-icon svg,
.dnb-core-style .dnb-icon svg {
width: inherit;
height: inherit;
shape-rendering: geometricprecision;
Expand Down Expand Up @@ -1475,9 +1476,12 @@ exports[`Button scss have to match snapshot 1`] = `
align-items: center;
justify-content: center;
}
h1 .dnb-icon, h2 .dnb-icon, h3 .dnb-icon, h4 .dnb-icon, h5 .dnb-icon, h6 .dnb-icon {
h1 > .dnb-icon, h2 > .dnb-icon, h3 > .dnb-icon, h4 > .dnb-icon, h5 > .dnb-icon, h6 > .dnb-icon {
vertical-align: middle;
}
p > .dnb-icon {
vertical-align: inherit;
}
.dnb-icon.dnb-skeleton {
color: var(--skeleton-color) !important;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1852,8 +1852,9 @@ exports[`DatePicker scss have to match snapshot 1`] = `
width: 1em;
height: 1em;
}
.dnb-icon img,
.dnb-icon svg {
.dnb-icon img, .dnb-core-style .dnb-icon img,
.dnb-icon svg,
.dnb-core-style .dnb-icon svg {
width: inherit;
height: inherit;
shape-rendering: geometricprecision;
Expand Down Expand Up @@ -1901,9 +1902,12 @@ exports[`DatePicker scss have to match snapshot 1`] = `
align-items: center;
justify-content: center;
}
h1 .dnb-icon, h2 .dnb-icon, h3 .dnb-icon, h4 .dnb-icon, h5 .dnb-icon, h6 .dnb-icon {
h1 > .dnb-icon, h2 > .dnb-icon, h3 > .dnb-icon, h4 > .dnb-icon, h5 > .dnb-icon, h6 > .dnb-icon {
vertical-align: middle;
}
p > .dnb-icon {
vertical-align: inherit;
}
.dnb-icon.dnb-skeleton {
color: var(--skeleton-color) !important;
}
Expand Down Expand Up @@ -2390,8 +2394,9 @@ button.dnb-button::-moz-focus-inner {
width: 1em;
height: 1em;
}
.dnb-icon img,
.dnb-icon svg {
.dnb-icon img, .dnb-core-style .dnb-icon img,
.dnb-icon svg,
.dnb-core-style .dnb-icon svg {
width: inherit;
height: inherit;
shape-rendering: geometricprecision;
Expand Down Expand Up @@ -2439,9 +2444,12 @@ button.dnb-button::-moz-focus-inner {
align-items: center;
justify-content: center;
}
h1 .dnb-icon, h2 .dnb-icon, h3 .dnb-icon, h4 .dnb-icon, h5 .dnb-icon, h6 .dnb-icon {
h1 > .dnb-icon, h2 > .dnb-icon, h3 > .dnb-icon, h4 > .dnb-icon, h5 > .dnb-icon, h6 > .dnb-icon {
vertical-align: middle;
}
p > .dnb-icon {
vertical-align: inherit;
}
.dnb-icon.dnb-skeleton {
color: var(--skeleton-color) !important;
}
Expand Down Expand Up @@ -3076,8 +3084,9 @@ html[data-visual-test] .dnb-input__input {
width: 1em;
height: 1em;
}
.dnb-icon img,
.dnb-icon svg {
.dnb-icon img, .dnb-core-style .dnb-icon img,
.dnb-icon svg,
.dnb-core-style .dnb-icon svg {
width: inherit;
height: inherit;
shape-rendering: geometricprecision;
Expand Down Expand Up @@ -3125,9 +3134,12 @@ html[data-visual-test] .dnb-input__input {
align-items: center;
justify-content: center;
}
h1 .dnb-icon, h2 .dnb-icon, h3 .dnb-icon, h4 .dnb-icon, h5 .dnb-icon, h6 .dnb-icon {
h1 > .dnb-icon, h2 > .dnb-icon, h3 > .dnb-icon, h4 > .dnb-icon, h5 > .dnb-icon, h6 > .dnb-icon {
vertical-align: middle;
}
p > .dnb-icon {
vertical-align: inherit;
}
.dnb-icon.dnb-skeleton {
color: var(--skeleton-color) !important;
}
Expand Down Expand Up @@ -3671,8 +3683,9 @@ legend.dnb-form-label {
width: 1em;
height: 1em;
}
.dnb-icon img,
.dnb-icon svg {
.dnb-icon img, .dnb-core-style .dnb-icon img,
.dnb-icon svg,
.dnb-core-style .dnb-icon svg {
width: inherit;
height: inherit;
shape-rendering: geometricprecision;
Expand Down Expand Up @@ -3720,9 +3733,12 @@ legend.dnb-form-label {
align-items: center;
justify-content: center;
}
h1 .dnb-icon, h2 .dnb-icon, h3 .dnb-icon, h4 .dnb-icon, h5 .dnb-icon, h6 .dnb-icon {
h1 > .dnb-icon, h2 > .dnb-icon, h3 > .dnb-icon, h4 > .dnb-icon, h5 > .dnb-icon, h6 > .dnb-icon {
vertical-align: middle;
}
p > .dnb-icon {
vertical-align: inherit;
}
.dnb-icon.dnb-skeleton {
color: var(--skeleton-color) !important;
}
Expand Down
Loading

0 comments on commit 11c1945

Please sign in to comment.