Skip to content

Commit

Permalink
rework: update Alert component to use ZendeskAlert directly with succ…
Browse files Browse the repository at this point in the history
…ess custom bg
  • Loading branch information
iacopolea committed Dec 12, 2024
1 parent 5bb898e commit 6a5b33e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 29 deletions.
6 changes: 0 additions & 6 deletions src/stories/notifications/alerts/_types.tsx

This file was deleted.

5 changes: 2 additions & 3 deletions src/stories/notifications/alerts/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Meta as ComponentMeta, StoryFn as Story } from "@storybook/react";
import { Alert } from ".";
import { AlertArgs } from "./_types";
import { Alert, AlertArgs } from ".";

const Template: Story<AlertArgs> = (args) => {
return (
Expand All @@ -25,7 +24,7 @@ Default.parameters = {
};

export default {
title: "Atoms/Alerts",
title: "Molecules/Notification/Alerts",
component: Alert,
parameters: {
// Sets a delay for the component's stories
Expand Down
24 changes: 4 additions & 20 deletions src/stories/notifications/alerts/index.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,11 @@
import { Alert as ZendeskAlert, Title as ZendeskTitle, Close as ZendeskClose } from '@zendeskgarden/react-notifications';
import styled from 'styled-components';
import { AlertArgs } from './_types';
import { IAlertProps } from '@zendeskgarden/react-notifications';

const UgAlert = styled(ZendeskAlert)`
background-color: white;
color: ${({ theme }) => theme.palette.grey[700]};
border-width: 2px;
font-size: ${({ theme }) => theme.fontSizes.sm};
`;

const UgAlertTitle = styled(ZendeskTitle)`
font-size: ${({ theme }) => theme.fontSizes.md};
`;
export interface AlertArgs extends IAlertProps {}

/**
* Breadcrumbs mark and communicate a user’s location in the product.
* <hr>
* Used for this:
- To show the user where they are in a nested navigation
- To provide a quick way to navigate to ancestor pages
*/
const Alert = (props: AlertArgs) => <UgAlert {...props}/>;
Alert.Title = UgAlertTitle;
const Alert = (props: AlertArgs) => <ZendeskAlert {...props}/>;
Alert.Title = ZendeskTitle;
Alert.Close = ZendeskClose;

export { Alert };
8 changes: 8 additions & 0 deletions src/stories/theme/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { colors } from "./colors";
import { fontWeights } from "./fontWeights";
import { palette } from "./palette";
import { getColor } from "./utils";
import { AlertArgs } from "../notifications/alerts";

export const components = {
...DEFAULT_THEME.components,
Expand Down Expand Up @@ -41,6 +42,13 @@ export const components = {
}),
};
},
"notifications.alert": ({ type }: AlertArgs) => {
return {
...(type === "success" && {
backgroundColor: getColor(colors.successHue, 10),
}),
};
},
"text.primary": () => ({
color: getColor(colors.primaryHue, 600),
}),
Expand Down
1 change: 1 addition & 0 deletions src/stories/theme/palette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const palette = {
"900": "#734A15",
},
"green": {
"10": "#EBF5F2",
"50": "#B3E8D9",
"100": "#80D9C0",
"200": "#66D1B3",
Expand Down

0 comments on commit 6a5b33e

Please sign in to comment.