From 4edbed2ba59936bc919c606c37502c8f0a46ca6a Mon Sep 17 00:00:00 2001 From: Kerry Date: Wed, 1 Nov 2023 12:03:14 +1300 Subject: [PATCH] Alert component tweaks (#121) * correct Alert border-radius, text sizee, use IconButton * prettier --- src/components/Alert/Alert.module.css | 26 +------------------ src/components/Alert/Alert.stories.tsx | 6 +++++ src/components/Alert/Alert.tsx | 18 ++++++++----- .../Alert/__snapshots__/Alert.test.tsx.snap | 4 +-- 4 files changed, 21 insertions(+), 33 deletions(-) diff --git a/src/components/Alert/Alert.module.css b/src/components/Alert/Alert.module.css index f6a89386..77001dee 100644 --- a/src/components/Alert/Alert.module.css +++ b/src/components/Alert/Alert.module.css @@ -22,7 +22,7 @@ limitations under the License. justify-content: start; gap: var(--cpd-space-3x); padding: var(--cpd-space-4x); - border-radius: 12px; + border-radius: 8px; border: 1px solid; } @@ -45,10 +45,6 @@ limitations under the License. flex: 1; } -.title { - font: var(--cpd-font-body-md-semibold); -} - [data-type="success"] :is(.title, .icon) { color: var(--cpd-color-green-900); } @@ -64,23 +60,3 @@ limitations under the License. .alert p { margin: 0; } - -[data-type] .close { - color: var(--cpd-color-gray-800); - border-radius: 50%; - padding: var(--cpd-space-scale); - cursor: pointer; -} - -@media (hover) { - .close:hover { - color: var(--cpd-color-icon-primary); - background: var(--cpd-color-alpha-gray-300); - cursor: pointer; - } -} - -.close:active { - color: var(--cpd-color-icon-primary); - background: var(--cpd-color-alpha-gray-300); -} diff --git a/src/components/Alert/Alert.stories.tsx b/src/components/Alert/Alert.stories.tsx index 9789d6c0..f7be9e7f 100644 --- a/src/components/Alert/Alert.stories.tsx +++ b/src/components/Alert/Alert.stories.tsx @@ -35,6 +35,12 @@ export default { console.log("Clicked!"); }, }, + parameters: { + design: { + type: "figma", + url: "https://www.figma.com/file/rTaQE2nIUSLav4Tg3nozq7/Compound-Web-Components?type=design&node-id=795-7802&mode=design&t=g71gv6nZdJA7QSGB-0", + }, + }, } as Meta; export const Success = { diff --git a/src/components/Alert/Alert.tsx b/src/components/Alert/Alert.tsx index 252402d5..65a144fd 100644 --- a/src/components/Alert/Alert.tsx +++ b/src/components/Alert/Alert.tsx @@ -23,6 +23,8 @@ import InfoIcon from "@vector-im/compound-design-tokens/icons/info.svg"; import CloseIcon from "@vector-im/compound-design-tokens/icons/close.svg"; import styles from "./Alert.module.css"; +import { Text } from "../Typography/Text"; +import { IconButton } from "../IconButton/IconButton"; type AlertProps = { /** @@ -82,19 +84,23 @@ export const Alert: React.FC> = ({ "aria-hidden": true, })}
-

{title}

-

{children}

+ + {title} + + + {children} +
{/* TODO: Setup an i18n function for the aria label below */} {onClose && ( - + > + + )} ); diff --git a/src/components/Alert/__snapshots__/Alert.test.tsx.snap b/src/components/Alert/__snapshots__/Alert.test.tsx.snap index c189d738..dc676b5a 100644 --- a/src/components/Alert/__snapshots__/Alert.test.tsx.snap +++ b/src/components/Alert/__snapshots__/Alert.test.tsx.snap @@ -24,12 +24,12 @@ exports[`Alert > renders 1`] = ` class="_content_6cfd7b" >

Title

Success!