Skip to content

Commit

Permalink
feat: add actions slot inside alert
Browse files Browse the repository at this point in the history
  • Loading branch information
hcarmonas committed Jun 2, 2022
1 parent 6d741c4 commit 2f7db2e
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/assets/img/icon/icon-warning-neutral.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions src/assets/scss/_alert.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@
}
}

&.warning-neutral {
@apply bg-gray2;

&:before {
background: url(~@img/icon/icon-warning-neutral.svg?url) no-repeat center center;
}
}

&.info {
@apply bg-grayPrimary text-white;

Expand Down Expand Up @@ -124,4 +132,12 @@
min-height: 106px;
}
}

.action-content {
@apply ml-4;

&:empty {
@apply hidden;
}
}
}
50 changes: 45 additions & 5 deletions src/components/Alert/Alert.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Alert from './Alert.vue';
import Button from '../Button/Button.vue';

export default {
title: 'Components/UI Elements/Alerts',
Expand All @@ -19,11 +20,22 @@ export default {
'success',
'error',
'warning',
'warning-neutral',
'info',
'info-neutral',
'info-line',
],
},
actionButton: {
control: { type: 'boolean' },
defaultValue: false,
description:
'Just a demonstration of how the button is going through the action slot',
table: {
type: { summary: 'boolean' },
defaultValue: { summary: 'false' },
},
},
},
parameters: {
componentSubtitle:
Expand All @@ -33,8 +45,19 @@ export default {

const Template = (args, { argTypes }) => ({
props: Object.keys(argTypes),
components: { Alert },
template: '<Alert v-bind="$props">{{label}}</Alert>',
components: { Alert, Button },
template: `
<Alert v-bind="$props">
{{label}}
<template v-if="$props.actionButton" #action>
<Button
id="action-button"
variant="primary"
>
Baixar
</Button>
</template>
</Alert>`,
});

export const Success = Template.bind({});
Expand All @@ -61,26 +84,43 @@ Warning.args = {
id: 'alert-3',
};

export const WarningNeutral = Template.bind({});
WarningNeutral.args = {
icon: true,
label: 'Warning Neutral',
variant: 'warning-neutral',
id: 'alert-4',
};

export const Info = Template.bind({});
Info.args = {
icon: true,
label: 'Info',
variant: 'info',
id: 'alert-4',
id: 'alert-5',
};

export const InfoNeutral = Template.bind({});
InfoNeutral.args = {
icon: true,
label: 'Info Neutral',
variant: 'info-neutral',
id: 'alert-5',
id: 'alert-6',
};

export const InfoLine = Template.bind({});
InfoLine.args = {
icon: true,
label: 'Info Line',
variant: 'info-line',
id: 'alert-6',
id: 'alert-7',
};

export const ActionButton = Template.bind({});
ActionButton.args = {
icon: true,
label: 'Baixe o CSV que disponibilizamos para ver e corrigir os problemas.',
variant: 'warning-neutral',
id: 'alert-8',
actionButton: true,
};
1 change: 1 addition & 0 deletions src/components/Alert/Alert.unit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ describe('Alert - Unit', () => {
variantValidator('success') &&
variantValidator('error') &&
variantValidator('warning') &&
variantValidator('warning-neutral') &&
variantValidator('info') &&
variantValidator('info-neutral') &&
variantValidator('info-line'),
Expand Down
5 changes: 5 additions & 0 deletions src/components/Alert/Alert.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
<slot />
</span>

<div class="action-content">
<slot name="action" />
</div>

<span v-if="close" class="alert-close" @click="hiddenAlert">
<em>Fechar</em>
</span>
Expand Down Expand Up @@ -77,6 +81,7 @@ export default {
'success',
'error',
'warning',
'warning-neutral',
'info',
'info-neutral',
'info-line',
Expand Down
2 changes: 1 addition & 1 deletion src/components/Alert/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

```js
size: ['sm', 'md', 'lg', 'xl'];
variant: ['success', 'error', 'warning', 'info', 'info-neutral', 'info-line'];
variant: ['success', 'error', 'warning', 'warning-neutral', 'info', 'info-neutral', 'info-line'];
close;
icon;
iconNumber;
Expand Down

0 comments on commit 2f7db2e

Please sign in to comment.