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

feat: add icon to the left and right button in alert component #246

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 10 additions & 0 deletions packages/components/alert/src/alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ export const alertProps = buildProps({
required: false,
default: undefined,
},
buttonLeftIcon: {
type: String,
required: false,
default: '',
},
buttonRightIcon: {
type: String,
required: false,
default: '',
},
isClosable: {
type: Boolean,
required: false,
Expand Down
2 changes: 2 additions & 0 deletions packages/components/alert/src/alert.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
v-if="buttonLabel"
:variant="variant"
class="puik-alert__button"
:right-icon="buttonRightIcon"
:left-icon="buttonLeftIcon"
:data-test="dataTest != undefined ? `button-${dataTest}` : undefined"
@click="click"
>
Expand Down
88 changes: 87 additions & 1 deletion packages/components/alert/stories/alert.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ export default {
buttonLabel: {
description: 'Label of the button',
},
buttonLeftIcon: {
description: 'Icon to the left button',
control: 'text',
},
buttonRightIcon: {
description: 'Icon to the right button',
control: 'text',
},
isClosable: {
description: 'Display a close button',
},
Expand Down Expand Up @@ -310,7 +318,85 @@ export const Danger: StoryObj = {
<span class="puik-alert__description">This a danger alert with a title and a description.</span>
</div>
</div>
<button class="puik-alert__button">Button</button>
<button class="puik-button puik-button--success puik-button--md puik-alert__button">
<div class="puik-icon puik-button__right-icon" style="font-size: 1.25rem;">
open_in_new
</div>
Button
</button>
</div>
`,
language: 'html',
},
},
},
}

export const WithIcon = {
render: () => ({
components: {
PuikAlert,
},
template: `
<div class="flex flex-col space-y-4">
<puik-alert title="Title" button-label="Button" button-right-icon="shopping_cart">This a success alert with a title, description and icon to the right of button.</puik-alert>
<puik-alert title="Title" button-label="Button" button-left-icon="shopping_cart">This a success alert with a title, description and icon to the left of button.</puik-alert>
</div>
`,
}),

parameters: {
docs: {
source: {
code: `
<!--VueJS Snippet-->
<puik-alert
title="Title"
button-label="Button"
button-left-icon="shopping_cart"
@click="click"
>
This a success alert with a title, description and icon to the right of button.
</puik-alert>
<puik-alert
title="Title"
button-label="Button"
button-left-icon="shopping_cart"
@click="click"
>
This a success alert with a title, description and icon to the right of button.
</puik-alert>

<!--HTML/CSS Snippet-->
<div class="puik-alert puik-alert--info puik-alert--no-borders" aria-live="polite">
<div class="puik-alert__content">
<span class="puik-icon puik-alert__icon">info</span>
<div class="puik-alert__text">
<p class="puik-alert__title">Title</p>
<span class="puik-alert__description">This a success alert with a title, description and icon to the ledt of button.</span>
</div>
</div>
<button class="puik-button puik-button--success puik-button--md puik-alert__button">
<div class="puik-icon puik-button__left-icon" style="font-size: 1.25rem;">
shopping_cart
</div>
Button
</button>
</div>
<div class="puik-alert puik-alert--info puik-alert--no-borders" aria-live="polite">
<div class="puik-alert__content">
<span class="puik-icon puik-alert__icon">info</span>
<div class="puik-alert__text">
<p class="puik-alert__title">Title</p>
<span class="puik-alert__description">This a success alert with a title, description and icon to the right of button.</span>
</div>
</div>
<button class="puik-button puik-button--success puik-button--md puik-alert__button">
<div class="puik-icon puik-button__right-icon" style="font-size: 1.25rem;">
shopping_cart
</div>
Button
</button>
</div>
`,
language: 'html',
Expand Down
Loading