Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alert component tweaks #121

Merged
merged 3 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 1 addition & 25 deletions src/components/Alert/Alert.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);
}
Expand All @@ -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);
}
6 changes: 6 additions & 0 deletions src/components/Alert/Alert.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof AlertComponent>;

export const Success = {
Expand Down
18 changes: 12 additions & 6 deletions src/components/Alert/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
/**
Expand Down Expand Up @@ -82,19 +84,23 @@ export const Alert: React.FC<PropsWithChildren<AlertProps>> = ({
"aria-hidden": true,
})}
<div className={styles.content}>
<p className={styles.title}>{title}</p>
<p className={styles.caption}>{children}</p>
<Text size="md" weight="semibold">
{title}
</Text>
<Text size="sm" weight="regular">
{children}
</Text>
</div>
{/* TODO: Setup an i18n function for the aria label below */}
{onClose && (
<CloseIcon
width={16}
height={16}
<IconButton
onClick={onClose}
aria-label="Close"
role="button"
className={styles.close}
/>
>
<CloseIcon />
</IconButton>
)}
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions src/components/Alert/__snapshots__/Alert.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ exports[`Alert > renders 1`] = `
class="_content_6cfd7b"
>
<p
class="_title_6cfd7b"
class="_font-body-md-semibold_489030"
>
Title
</p>
<p
class="_caption_6cfd7b"
class="_font-body-sm-regular_489030"
>
Success!
</p>
Expand Down
Loading