Skip to content

Commit

Permalink
feat(Alert): add new bordered style (previously called border)
Browse files Browse the repository at this point in the history
- deprecate `border` props in favor of new `bordered` prop
  • Loading branch information
gravitano committed Jun 9, 2023
1 parent c1be516 commit 2663c38
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 11 deletions.
53 changes: 44 additions & 9 deletions packages/alert/src/VAlert.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ export default {
},
},
args: {
modelValue: '',
label: 'Alert text',
dismissable: false,
solid: false,
outlined: false,
icon: '',
border: '',
},
} as Meta;

Expand All @@ -39,7 +32,14 @@ const Template: Story = (args) => ({
},
template: `
<div class="space-y-2">
<my-component v-for="color in themeColors" :key="color" v-bind="args" :color="color">{{ args.label }}</my-component>
<my-component
v-for="color in themeColors"
:key="color"
v-bind="args"
:color="color"
>
You changes have been saved.
</my-component>
</div>
`,
});
Expand Down Expand Up @@ -89,6 +89,8 @@ Outlined.parameters = {
export const Bordered = Template.bind({});
Bordered.args = {
border: true,
dismissable: true,
icon: 'ic:round-info'
};
Bordered.parameters = {
docs: {
Expand All @@ -98,6 +100,39 @@ Bordered.parameters = {
},
};

export const BorderPosition = (args: any) => ({
components: {VAlert, VAlertTitle, Icon},
setup() {
const positions = ['left', 'top', 'right', 'bottom']
return {args, positions};
},
template: `
<v-alert
v-for="position in positions"
:key="position"
:border-position="position"
class="mb-2"
bordered
v-bind="args"
>
<VAlertTitle>Alert: {{ position }}<VAlertTitle>
Change a few things up and try submitting again.
</v-alert>
`,
});

export const Tile = Template.bind({});
Tile.args = {
tile: true,
};
Tile.parameters = {
docs: {
source: {
code: `<v-alert tile>Alert text</v-alert>`,
},
},
};

export const Dismissable = Template.bind({});
Dismissable.args = {
dismissable: true,
Expand Down Expand Up @@ -276,4 +311,4 @@ export const Group: StoryFn<typeof VAlert> = (args) => ({
</VAlertGroup>
</div>
`,
});
});
22 changes: 20 additions & 2 deletions packages/alert/src/VAlert.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import {computed, toRefs, ref, watch, provide, onMounted} from 'vue';
import {computed, toRefs, ref, watch, provide, onMounted, PropType} from 'vue';
import Icon from '@morpheme/icon';
import {AlertSymbol} from './api';
Expand Down Expand Up @@ -35,6 +35,9 @@ const props = defineProps({
type: Boolean,
default: false,
},
/**
* @deprecated Use `bordered` instead
*/
border: {
type: [String, Boolean],
default: false,
Expand All @@ -51,6 +54,18 @@ const props = defineProps({
type: String,
default: 'xs',
},
tile: {
type: Boolean,
default: false,
},
bordered: {
type: Boolean,
default: false,
},
borderPosition: {
type: String as PropType<'top' | 'bottom' | 'left' | 'right'>,
default: 'left',
},
});
const {modelValue, color} = toRefs(props);
Expand All @@ -74,10 +89,13 @@ watch(isOpen, (val) => {
const classes = computed(() => {
return [
`alert-${props.color}`,
`alert__bordered--${props.borderPosition}`,
{
'alert--outlined': props.outlined,
'alert--solid': props.solid,
'alert--bordered': props.border,
'alert--bordered': props.border || props.bordered,
'alert__bordered': props.border || props.bordered,
'alert--tile': props.tile
},
];
});
Expand Down
57 changes: 57 additions & 0 deletions packages/themes/src/morpheme/_alert.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
font-size: var(--alert-font-size);
line-height: var(--alert-line-height);

&--tile {
--alert-border-radius: 0;
}

// Element
&-content {
flex: 1;
Expand Down Expand Up @@ -251,4 +255,57 @@
font-weight: var(--alert-title-font-weight, 600);
margin-bottom: var(--alert-title-margin-bottom, 4px);
}

// bordered
&__bordered {
border-width: 1px;
border-style: solid;
border-color: var(--alert-border-color);
--alert-border-width: 4px;

&--top {
border-top-width: var(--alert-border-width);
}

&--right {
border-right-width: var(--alert-border-width);
}

&--bottom {
border-bottom-width: var(--alert-border-width);
}

&--left {
border-left-width: var(--alert-border-width);
}

// Colors
&.alert-primary {
--alert-border-color: var(--color-primary-500);
}

&.alert-secondary {
--alert-border-color: var(--color-secondary-500);
}

&.alert-info {
--alert-border-color: var(--color-info-500);
}

&.alert-warning {
--alert-border-color: var(--color-warning-500);
}

&.alert-success {
--alert-border-color: var(--color-success-500);
}

&.alert-error {
--alert-border-color: var(--color-error-500);
}

&.alert-dark {
--alert-border-color: var(--color-gray-500);
}
}
}

1 comment on commit 2663c38

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for morpheme-kitchen-sink ready!

✅ Preview
https://morpheme-kitchen-sink-n9xy4qq0v-gravitano.vercel.app

Built with commit 2663c38.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.