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

restore old Alert api #1515

Merged
merged 6 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
4 changes: 2 additions & 2 deletions .changeset/odd-crabs-approve.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'@itwin/itwinui-react': major
'@itwin/itwinui-react': minor
---

Alert composition has been updated such that it is now made up of customizable subcomponents, thus removing the `onClose`, `clickableText`, and `clickableTextProps` props from `Alert`.
Alert can now be used through customizable subcomponents. The `onClose`, `clickableText`, and `clickableTextProps` props have been deprecated.
28 changes: 14 additions & 14 deletions apps/storybook/src/Alert.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default {

export const Informational: Story<AlertProps> = (args) => {
return (
<Alert type='informational' {...args}>
<Alert.Wrapper type='informational' {...args}>
<Alert.Icon />
<Alert.Message>
This is an informational message.
Expand All @@ -30,7 +30,7 @@ export const Informational: Story<AlertProps> = (args) => {
</Alert.Action>
</Alert.Message>
<Alert.CloseButton onClick={action('Close!')} />
</Alert>
</Alert.Wrapper>
);
};

Expand All @@ -41,7 +41,7 @@ Informational.args = {

export const Positive: Story<AlertProps> = (args) => {
return (
<Alert type='positive' {...args}>
<Alert.Wrapper type='positive' {...args}>
<Alert.Icon />
<Alert.Message>
This is a positive message.
Expand All @@ -50,7 +50,7 @@ export const Positive: Story<AlertProps> = (args) => {
</Alert.Action>
</Alert.Message>
<Alert.CloseButton onClick={action('Close!')} />
</Alert>
</Alert.Wrapper>
);
};

Expand All @@ -61,7 +61,7 @@ Positive.args = {

export const Warning: Story<AlertProps> = (args) => {
return (
<Alert type='warning' {...args}>
<Alert.Wrapper type='warning' {...args}>
<Alert.Icon />
<Alert.Message>
This is a warning message.
Expand All @@ -70,7 +70,7 @@ export const Warning: Story<AlertProps> = (args) => {
</Alert.Action>
</Alert.Message>
<Alert.CloseButton onClick={action('Close!')} />
</Alert>
</Alert.Wrapper>
);
};

Expand All @@ -81,7 +81,7 @@ Warning.args = {

export const Negative: Story<AlertProps> = (args) => {
return (
<Alert type='negative' {...args}>
<Alert.Wrapper type='negative' {...args}>
<Alert.Icon />
<Alert.Message>
This is a negative message.
Expand All @@ -90,7 +90,7 @@ export const Negative: Story<AlertProps> = (args) => {
</Alert.Action>
</Alert.Message>
<Alert.CloseButton onClick={action('Close!')} />
</Alert>
</Alert.Wrapper>
);
};

Expand All @@ -109,7 +109,7 @@ export const Sticky: Story<AlertProps> = (args) => {
border: 'solid 0.5px',
}}
>
<Alert type='informational' isSticky={true} {...args}>
<Alert.Wrapper type='informational' isSticky={true} {...args}>
<Alert.Icon />
<Alert.Message>
This is sticky!
Expand All @@ -118,7 +118,7 @@ export const Sticky: Story<AlertProps> = (args) => {
</Alert.Action>
</Alert.Message>
<Alert.CloseButton onClick={action('Close!')} />
</Alert>
</Alert.Wrapper>
<p style={{ margin: 0, padding: '8px' }}>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
Expand Down Expand Up @@ -171,10 +171,10 @@ Sticky.args = {

export const Empty: Story<AlertProps> = (args) => {
return (
<Alert type='informational' {...args}>
<Alert.Wrapper type='informational' {...args}>
<Alert.Icon />
<Alert.Message>This is an empty info message.</Alert.Message>
</Alert>
</Alert.Wrapper>
);
};

Expand All @@ -185,15 +185,15 @@ Empty.args = {

export const CustomIcon: Story<AlertProps> = (args) => {
return (
<Alert type='informational' {...args}>
<Alert.Wrapper type='informational' {...args}>
<Alert.Icon>
<SvgSmileyHappy />
</Alert.Icon>
<Alert.Message>This is an info message with a custom icon.</Alert.Message>
<Alert.CloseButton onClick={action('Close!')}>
<SvgPlaceholder />
</Alert.CloseButton>
</Alert>
</Alert.Wrapper>
);
};

Expand Down
4 changes: 2 additions & 2 deletions apps/website/src/demos/Alert.demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import { Alert, ThemeProvider } from '@itwin/itwinui-react';
export default function AlertDemo() {
return (
<ThemeProvider theme='dark'>
<Alert style={{ minWidth: 'min(100%, 350px)' }}>
<Alert.Wrapper style={{ minWidth: 'min(100%, 350px)' }}>
<Alert.Icon />
<Alert.Message>
This is an alert
<Alert.Action onClick={() => console.log('Clicked more info!')}>Learn more</Alert.Action>
</Alert.Message>
<Alert.CloseButton onClick={() => console.log('CLOSED')} />
</Alert>
</Alert.Wrapper>
</ThemeProvider>
);
}
7 changes: 5 additions & 2 deletions examples/Alert.informational.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { Alert } from '@itwin/itwinui-react';

export default () => {
return (
<Alert type='informational' style={{ minWidth: 'min(100%, 350px)' }}>
<Alert.Wrapper
type='informational'
style={{ minWidth: 'min(100%, 350px)' }}
>
<Alert.Icon />
<Alert.Message>
This is an informational alert
Expand All @@ -16,6 +19,6 @@ export default () => {
</Alert.Action>
</Alert.Message>
<Alert.CloseButton onClick={() => console.log('CLOSED')} />
</Alert>
</Alert.Wrapper>
);
};
4 changes: 2 additions & 2 deletions examples/Alert.inline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export default () => {
return (
<div>
<p style={{ marginBottom: 12 }}>Page content before alert.</p>
<Alert style={{ minWidth: 'min(100%, 280px)' }}>
<Alert.Wrapper style={{ minWidth: 'min(100%, 280px)' }}>
<Alert.Message>This is a inline alert.</Alert.Message>
</Alert>
</Alert.Wrapper>
<p style={{ marginTop: 12 }}>Page content after alert.</p>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions examples/Alert.main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Alert } from '@itwin/itwinui-react';

export default () => {
return (
<Alert style={{ minWidth: 'min(100%, 350px)' }}>
<Alert.Wrapper style={{ minWidth: 'min(100%, 350px)' }}>
<Alert.Icon />
<Alert.Message>
This is an alert
Expand All @@ -16,6 +16,6 @@ export default () => {
</Alert.Action>
</Alert.Message>
<Alert.CloseButton onClick={() => console.log('CLOSED')} />
</Alert>
</Alert.Wrapper>
);
};
4 changes: 2 additions & 2 deletions examples/Alert.negative.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Alert } from '@itwin/itwinui-react';

export default () => {
return (
<Alert type='negative' style={{ minWidth: 'min(100%, 350px)' }}>
<Alert.Wrapper type='negative' style={{ minWidth: 'min(100%, 350px)' }}>
<Alert.Icon />
<Alert.Message>
This is a negative alert
Expand All @@ -16,6 +16,6 @@ export default () => {
</Alert.Action>
</Alert.Message>
<Alert.CloseButton onClick={() => console.log('CLOSED')} />
</Alert>
</Alert.Wrapper>
);
};
4 changes: 2 additions & 2 deletions examples/Alert.positive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Alert } from '@itwin/itwinui-react';

export default () => {
return (
<Alert type='positive' style={{ minWidth: 'min(100%, 350px)' }}>
<Alert.Wrapper type='positive' style={{ minWidth: 'min(100%, 350px)' }}>
<Alert.Icon />
<Alert.Message>
This is a positive alert
Expand All @@ -16,6 +16,6 @@ export default () => {
</Alert.Action>
</Alert.Message>
<Alert.CloseButton onClick={() => console.log('CLOSED')} />
</Alert>
</Alert.Wrapper>
);
};
4 changes: 2 additions & 2 deletions examples/Alert.sticky.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Alert } from '@itwin/itwinui-react';
export default () => {
return (
<div>
<Alert isSticky>
<Alert.Wrapper isSticky>
<Alert.Icon />
<Alert.Message>
This is a sticky alert
Expand All @@ -17,7 +17,7 @@ export default () => {
</Alert.Action>
</Alert.Message>
<Alert.CloseButton onClick={() => console.log('CLOSED')} />
</Alert>
</Alert.Wrapper>
<p>Page content.</p>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions examples/Alert.warning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Alert } from '@itwin/itwinui-react';

export default () => {
return (
<Alert type='warning' style={{ minWidth: 'min(100%, 350px)' }}>
<Alert.Wrapper type='warning' style={{ minWidth: 'min(100%, 350px)' }}>
<Alert.Icon />
<Alert.Message>
This is a warning alert
Expand All @@ -16,6 +16,6 @@ export default () => {
</Alert.Action>
</Alert.Message>
<Alert.CloseButton onClick={() => console.log('CLOSED')} />
</Alert>
</Alert.Wrapper>
);
};
Loading