Allow specifying alignment for ButtonGroup.

This commit is contained in:
baldo 2022-08-23 15:11:09 +02:00
parent 4db53af7ce
commit 5ae27f530e
4 changed files with 33 additions and 5 deletions

View file

@ -1,15 +1,16 @@
<script setup lang="ts"> <script setup lang="ts">
import type {ButtonSize} from "@/types"; import type {ButtonSize, ComponentAlignment} from "@/types";
interface Props { interface Props {
buttonSize: ButtonSize; buttonSize: ButtonSize;
align: ComponentAlignment;
} }
const props = defineProps<Props>() const props = defineProps<Props>()
</script> </script>
<template> <template>
<div :class="['button-group', buttonSize]"> <div :class="['button-group', buttonSize, align]">
<slot></slot> <slot></slot>
</div> </div>
</template> </template>
@ -20,8 +21,17 @@ const props = defineProps<Props>()
.button-group { .button-group {
display: flex; display: flex;
justify-content: center;
flex-wrap: wrap; flex-wrap: wrap;
margin: {
left: -$button-margin;
right: -$button-margin;
}
@each $align in (left, center, right) {
&.#{$align} {
justify-content: $align;
}
}
button { button {
margin: $button-margin; margin: $button-margin;
@ -32,15 +42,22 @@ const props = defineProps<Props>()
.button-group { .button-group {
flex-direction: column; flex-direction: column;
margin: {
left: 0;
right: 0;
}
button { button {
margin: $button-margin 0; margin: $button-margin 0;
width: 100%; width: 100%;
} }
} }
} }
@include page-breakpoint(smaller) { @include page-breakpoint(smaller) {
.button-group { .button-group {
align-items: center; align-items: center;
button { button {
flex-grow: 1; flex-grow: 1;
max-width: 80%; max-width: 80%;

View file

@ -11,6 +11,7 @@ $white: #ffffff;
// Colors // Colors
$variant-colors: ( $variant-colors: (
primary: #e5287a, primary: #e5287a,
secondary: $gray-light,
success: #4ba74b, success: #4ba74b,
warning: #fdbc41, warning: #fdbc41,
danger: #ef5652, danger: #ef5652,
@ -18,6 +19,7 @@ $variant-colors: (
); );
$variant-text-colors: ( $variant-text-colors: (
primary: $black, primary: $black,
secondary: $black,
success: $black, success: $black,
warning: $black, warning: $black,
danger: $black, danger: $black,
@ -25,6 +27,7 @@ $variant-text-colors: (
); );
$variant-color-primary: map-get($variant-colors, primary); $variant-color-primary: map-get($variant-colors, primary);
$variant-color-secondary: map-get($variant-colors, secondary);
$variant-color-success: map-get($variant-colors, success); $variant-color-success: map-get($variant-colors, success);
$variant-color-warning: map-get($variant-colors, warning); $variant-color-warning: map-get($variant-colors, warning);
$variant-color-danger: map-get($variant-colors, danger); $variant-color-danger: map-get($variant-colors, danger);

View file

@ -6,8 +6,15 @@ export enum ButtonSize {
LARGE = "large", LARGE = "large",
} }
export enum ComponentAlignment {
LEFT = "left",
CENTER = "center",
RIGHT = "right",
}
export enum ComponentVariant { export enum ComponentVariant {
PRIMARY = "primary", PRIMARY = "primary",
SECONDARY = "secondary",
SUCCESS = "success", SUCCESS = "success",
WARNING = "warning", WARNING = "warning",
DANGER = "danger", DANGER = "danger",

View file

@ -2,7 +2,8 @@
import ActionButton from "@/components/form/ActionButton.vue"; import ActionButton from "@/components/form/ActionButton.vue";
import ButtonGroup from "@/components/form/ButtonGroup.vue"; import ButtonGroup from "@/components/form/ButtonGroup.vue";
import PageContainer from "@/components/page/PageContainer.vue"; import PageContainer from "@/components/page/PageContainer.vue";
import {ButtonSize, ComponentVariant} from "@/types";</script> import {ButtonSize, ComponentAlignment, ComponentVariant} from "@/types";
</script>
<template> <template>
<PageContainer> <PageContainer>
@ -12,7 +13,7 @@ import {ButtonSize, ComponentVariant} from "@/types";</script>
Knoten in Betrieb und möchtest seine Daten ändern? Oder Du möchtest einen Knoten, der nicht mehr in Betrieb Knoten in Betrieb und möchtest seine Daten ändern? Oder Du möchtest einen Knoten, der nicht mehr in Betrieb
ist löschen? Dann bist Du hier richtig!</p> ist löschen? Dann bist Du hier richtig!</p>
<ButtonGroup :button-size="ButtonSize.LARGE"> <ButtonGroup class="actions" :align="ComponentAlignment.CENTER" :button-size="ButtonSize.LARGE">
<ActionButton <ActionButton
:variant="ComponentVariant.INFO" :variant="ComponentVariant.INFO"
:size="ButtonSize.LARGE" :size="ButtonSize.LARGE"