Skip to content

Commit

Permalink
SWED-2276 refactor CSS Alert component clean
Browse files Browse the repository at this point in the history
  • Loading branch information
goldenraphti committed Jan 5, 2024
1 parent 71e0b6b commit 292fc74
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ exports[`Components: ActionList renders 1`] = `
<i
aria-hidden="true"
className="at-exclamation-triangle alert-icon"
className="at-exclamation-triangle"
/>
<p>
<b>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exports[`Documentation: Alerts Content guidelines renders 1`] = `
<i
aria-hidden="true"
className="at-info-circle alert-icon"
className="at-info-circle"
/>
<p>
<b>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2507,7 +2507,7 @@ exports[`Dashboard: Charts renders 1`] = `
<i
aria-hidden="true"
className="at-exclamation-triangle alert-icon"
className="at-exclamation-triangle"
/>
<p>
<b>
Expand Down Expand Up @@ -3316,7 +3316,7 @@ exports[`Dashboard: Charts renders 1`] = `
<i
aria-hidden="true"
className="at-info-circle alert-icon"
className="at-info-circle"
/>
<p>
<b>
Expand Down Expand Up @@ -3640,7 +3640,7 @@ exports[`Dashboard: Charts renders 1`] = `
<i
aria-hidden="true"
className="at-info-circle alert-icon"
className="at-info-circle"
/>
<p>
<b>
Expand Down Expand Up @@ -3868,7 +3868,7 @@ exports[`Dashboard: Charts renders 1`] = `
<i
aria-hidden="true"
className="at-info-circle alert-icon"
className="at-info-circle"
/>
<p>
<b>
Expand Down Expand Up @@ -4167,7 +4167,7 @@ exports[`Dashboard: Charts renders 1`] = `
<i
aria-hidden="true"
className="at-info-circle alert-icon"
className="at-info-circle"
/>
<p>
<b>
Expand Down Expand Up @@ -4494,7 +4494,7 @@ exports[`Dashboard: Charts renders 1`] = `
<i
aria-hidden="true"
className="at-info-circle alert-icon"
className="at-info-circle"
/>
<p>
<b>
Expand Down Expand Up @@ -4847,7 +4847,7 @@ exports[`Dashboard: Charts renders 1`] = `
<i
aria-hidden="true"
className="at-info-circle alert-icon"
className="at-info-circle"
/>
<p>
<b>
Expand Down Expand Up @@ -5086,7 +5086,7 @@ exports[`Dashboard: Charts renders 1`] = `
<i
aria-hidden="true"
className="at-info-circle alert-icon"
className="at-info-circle"
/>
<p>
<b>
Expand Down Expand Up @@ -5313,7 +5313,7 @@ exports[`Dashboard: Charts renders 1`] = `
<i
aria-hidden="true"
className="at-info-circle alert-icon"
className="at-info-circle"
/>
<p>
<b>
Expand Down Expand Up @@ -5636,7 +5636,7 @@ exports[`Dashboard: Charts renders 1`] = `
<i
aria-hidden="true"
className="at-info-circle alert-icon"
className="at-info-circle"
/>
<p>
<b>
Expand Down Expand Up @@ -5893,7 +5893,7 @@ exports[`Dashboard: Charts renders 1`] = `
<i
aria-hidden="true"
className="at-info-circle alert-icon"
className="at-info-circle"
/>
<p>
<b>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ Array [
<i
aria-hidden="true"
className="at-warning alert-icon"
className="at-warning"
/>
<p>
<b>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,8 @@ exports[`GetStarted: ForDevelopers Installation renders 1`] = `
>
<i
aria-hidden="true"
className="material-icons alert-icon"
>
info
</i>
className="at-info-circle"
/>
<p>
<b>
Recommended way:
Expand Down Expand Up @@ -439,10 +437,8 @@ exports[`GetStarted: ForDevelopers Installation renders 1`] = `
>
<i
aria-hidden="true"
className="material-icons alert-icon"
>
info
</i>
className="at-info-circle"
/>
<p>
<b>
Standards:
Expand Down Expand Up @@ -717,10 +713,8 @@ exports[`GetStarted: ForDevelopers Installation renders 1`] = `
>
<i
aria-hidden="true"
className="material-icons alert-icon"
>
info
</i>
className="at-info-circle"
/>
<p>
<b>
Import only once:
Expand Down Expand Up @@ -812,10 +806,8 @@ exports[`GetStarted: ForDevelopers Installation renders 1`] = `
>
<i
aria-hidden="true"
className="material-icons alert-icon"
>
info
</i>
className="at-info-circle"
/>
<p>
<b>
Web-perf:
Expand Down Expand Up @@ -1186,10 +1178,8 @@ exports[`GetStarted: ForDevelopers Installation renders 1`] = `
>
<i
aria-hidden="true"
className="material-icons alert-icon"
>
info
</i>
className="at-info-circle"
/>
<p>
<b>
Target Browser:
Expand Down
20 changes: 5 additions & 15 deletions src/App/GetStarted/get-started/ForDevelopers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ const InstallJS = () => (
</ul>
</p>
<div className="alert alert-informative">
<i className="material-icons alert-icon" aria-hidden="true">
info
</i>
<i className="at-info-circle" aria-hidden="true"></i>
<p>
<b>Recommended way:</b> Importing component per component means you do
not end up importing the javascript for components you are not using.
Expand All @@ -75,9 +73,7 @@ const InstallJS = () => (
dg.script.initAll();
</ComponentPreview>
<div className="alert alert-informative">
<i className="material-icons alert-icon" aria-hidden="true">
info
</i>
<i className="at-info-circle" aria-hidden="true"></i>
<p>
<b>Standards:</b> Our JS uses modern features such as optional-chaining.
If you&apos;re experiencing issues you might want to look at our browser
Expand Down Expand Up @@ -134,9 +130,7 @@ const InstallCSSLESS = () => (
],
</ComponentPreview>
<div className="alert alert-informative">
<i className="material-icons alert-icon" aria-hidden="true">
info
</i>
<i className="at-info-circle" aria-hidden="true"></i>
<p>
<b>Import only once:</b> Either import from the style file <em>OR</em>{" "}
from the build tool. If you import through both you will end up loading
Expand All @@ -161,9 +155,7 @@ const InstallIndividualComponents = () => (
url(&quot;@swedbankpay/design-guide/src/less/components/expandable.less&quot;);
</ComponentPreview>
<div className="alert alert-informative">
<i className="material-icons alert-icon" aria-hidden="true">
info
</i>
<i className="at-info-circle" aria-hidden="true"></i>
<p>
<b>Web-perf:</b> Importing the style of individual components means
fewer css imported, hence smaller file size. If you do not want to
Expand Down Expand Up @@ -356,9 +348,7 @@ const BrowserSupport = () => (
))}
</div>
<div className="alert alert-informative mt-4">
<i className="material-icons alert-icon" aria-hidden="true">
info
</i>
<i className="at-info-circle" aria-hidden="true"></i>
<p>
<b>Target Browser:</b> &quot;Last 3 versions, &gt; 1%, not dead&quot;
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1543,7 +1543,7 @@ exports[`Forms: index renders 1`] = `
<i
aria-hidden="true"
className="at-exclamation-triangle alert-icon"
className="at-exclamation-triangle"
/>
<p>
<b>
Expand Down
16 changes: 8 additions & 8 deletions src/App/components/Alert/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exports[`Component: Alert prop type is marked as required 1`] = `
<i
aria-hidden="true"
className="at- alert-icon"
className="at-"
/>
Expand All @@ -23,7 +23,7 @@ exports[`Component: Alert renders an alert with a close-button 1`] = `
<i
aria-hidden="true"
className="at- alert-icon"
className="at-"
/>
Expand Down Expand Up @@ -56,7 +56,7 @@ exports[`Component: Alert renders an alert with icon 1`] = `
<i
aria-hidden="true"
className="at-test alert-icon"
className="at-test"
/>
Expand All @@ -71,7 +71,7 @@ exports[`Component: Alert renders an alert with text 1`] = `
<i
aria-hidden="true"
className="at- alert-icon"
className="at-"
/>
<p>
test
Expand All @@ -89,7 +89,7 @@ exports[`Component: Alert renders an alert with the correct type recieved from i
<i
aria-hidden="true"
className="at- alert-icon"
className="at-"
/>
Expand All @@ -104,7 +104,7 @@ exports[`Component: Alert renders an alert without a close-button if no close pr
<i
aria-hidden="true"
className="at- alert-icon"
className="at-"
/>
Expand All @@ -119,7 +119,7 @@ exports[`Component: Alert renders an alert without an icon if no icon prop is pr
<i
aria-hidden="true"
className="at- alert-icon"
className="at-"
/>
Expand All @@ -134,7 +134,7 @@ exports[`Component: Alert renders an alert without text if no text prop is provi
<i
aria-hidden="true"
className="at- alert-icon"
className="at-"
/>
Expand Down
2 changes: 1 addition & 1 deletion src/App/components/Alert/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Alert = ({ id, type, icon = "", close, text, className }) => {
return (
<div id={id} className={alertClasses}>
{"\n"}
<i className={`at-${icon} alert-icon`} aria-hidden="true"></i>
<i className={`at-${icon}`} aria-hidden="true"></i>
{text}
{"\n"}
{close ? (
Expand Down
2 changes: 1 addition & 1 deletion src/App/components/Alert/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe("Component: Alert", () => {
const { container } = render(<Alert type="test" icon="test" />);

expect(container.querySelectorAll("i").length).toBe(1);
expect(container.querySelector("i")).toHaveClass("at-test alert-icon");
expect(container.querySelector("i")).toHaveClass("at-test");
// checks icon is hidden for screen-readers
expect(container.querySelector("i")).toHaveAttribute("aria-hidden", "true");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exports[`Utilities: DeprecatedComponentAlert renders 1`] = `
<i
aria-hidden="true"
className="at-exclamation-triangle alert-icon"
className="at-exclamation-triangle"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exports[`Utilities: ExperimentalComponentAlert renders 1`] = `
<i
aria-hidden="true"
className="at-exclamation-triangle alert-icon"
className="at-exclamation-triangle"
/>
Expand Down
2 changes: 1 addition & 1 deletion src/less/components/alert.less
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
border-radius: 0.25rem;
background-color: var(--color-bg);

& > i {
& > i[aria-hidden="true"]:first-child {
color: var(--color-icon);
margin-right: 1rem;
}
Expand Down

0 comments on commit 292fc74

Please sign in to comment.