bonkers-ui 1.0.9 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bonkers-ui",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "scripts": {
5
5
  "storybook": "start-storybook -p 6006",
6
6
  "build-storybook": "build-storybook",
@@ -0,0 +1,6 @@
1
+ export enum EAlertTypes {
2
+ PRIMARY = "PRIMARY",
3
+ SECONDARY = "SECONDARY",
4
+ ERROR = "ERROR",
5
+ WARNING = "WARNING",
6
+ }
@@ -0,0 +1,2 @@
1
+ export { default } from "./ui-alert.vue";
2
+ export { EAlertTypes } from "./_types";
@@ -0,0 +1,38 @@
1
+ import UiAlert from "./ui-alert.vue";
2
+ import type { Story } from "@storybook/vue3";
3
+ import { EAlertTypes } from "./_types";
4
+
5
+ export default {
6
+ title: "Components/ui-alert",
7
+ component: UiAlert,
8
+ argTypes: {
9
+ kind: {
10
+ control: { type: "select" },
11
+ options: Object.values(EAlertTypes),
12
+ description: "The button kinds",
13
+ },
14
+ },
15
+ args: {
16
+ slot: "some description text: lorem",
17
+ kind: EAlertTypes.WARNING
18
+ }
19
+ };
20
+
21
+ type TComponentProps = InstanceType<typeof UiAlert>["$props"];
22
+
23
+ const Template: Story<TComponentProps> = (args) => ({
24
+ components: { UiAlert },
25
+ setup() {
26
+ return { args };
27
+ },
28
+ template: `
29
+ <ui-alert
30
+ :kind="args.kind"
31
+ :icon="['far', 'face-smile']"
32
+ >
33
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
34
+ </ui-alert>
35
+ `
36
+ });
37
+
38
+ export const Default = Template.bind({});
@@ -0,0 +1,40 @@
1
+ <template>
2
+ <div
3
+ class="ui-alert flex gap-sm p-sm border rounded-lg"
4
+ :class="[
5
+ (!kind || kind === EAlertTypes.PRIMARY) && 'border-primary',
6
+ kind === EAlertTypes.WARNING && 'border-warning',
7
+ kind === EAlertTypes.ERROR && 'border-error',
8
+ kind === EAlertTypes.SECONDARY && 'border-secondary',
9
+ ]"
10
+ >
11
+ <ui-icon
12
+ :icon-name="icon"
13
+ :size="ESize.SM"
14
+ :class="[
15
+ (!kind || kind === EAlertTypes.PRIMARY) && 'text-primary',
16
+ kind === EAlertTypes.WARNING && 'text-warning',
17
+ kind === EAlertTypes.ERROR && 'text-error',
18
+ kind === EAlertTypes.SECONDARY && 'text-secondary',
19
+ ]"
20
+ />
21
+ <ui-typography
22
+ :size="ETypographySizes.XS"
23
+ line-height
24
+ >
25
+ <slot />
26
+ </ui-typography>
27
+ </div>
28
+ </template>
29
+
30
+ <script lang="ts" setup>
31
+ import UiTypography, { ETypographySizes } from "../ui-typography";
32
+ import UiIcon, { type TIconName } from "../ui-icon";
33
+ import { ESize } from "../../_types/sizing";
34
+ import { EAlertTypes } from "./_types";
35
+
36
+ defineProps<{
37
+ icon: TIconName
38
+ kind?: EAlertTypes
39
+ }>();
40
+ </script>
@@ -32,7 +32,7 @@ const Template: Story<TComponentProps> = (args) => ({
32
32
  return { args };
33
33
  },
34
34
  template: `
35
- <ui-badge :icon="['far', 'face-smile']" v-bind="args">
35
+ <ui-badge :icon="['far', 'face-smile']" v-bind="args" class="inline-flex">
36
36
  {{ args.slot }}
37
37
  </ui-badge>
38
38
  `,
@@ -1,6 +1,6 @@
1
1
  <template>
2
- <span
3
- class="ui-badge rounded-full inline-flex items-center"
2
+ <div
3
+ class="ui-badge rounded-full flex items-center content-center gap-xxs"
4
4
  :class="[
5
5
  (!size || size === EBadgeSize.SMALL) && 'px-xs py-xxs',
6
6
  (!kind || kind === EBadgeKind.PRIMARY) && 'bg-primary-alt-300 text-primary-alt-700',
@@ -14,24 +14,23 @@
14
14
  >
15
15
  <ui-icon
16
16
  v-if="icon"
17
- class="mr-xxs"
18
17
  :size="ESize.SM"
19
18
  :icon-name="icon"
20
19
  />
21
20
 
22
21
  <ui-typography
23
- is="span"
22
+ v-if="slots.default"
24
23
  :size="getBadgeSize"
25
24
  :weight="ETextWeight.SEMI_BOLD"
26
25
  class="whitespace-nowrap"
27
26
  >
28
27
  <slot />
29
28
  </ui-typography>
30
- </span>
29
+ </div>
31
30
  </template>
32
31
 
33
32
  <script lang="ts" setup>
34
- import { computed } from "vue";
33
+ import { computed, useSlots } from "vue";
35
34
  import { EBadgeKind, EBadgeSize } from "./_typings";
36
35
  import UiIcon, { type TIconName } from "../ui-icon";
37
36
  import { ESize } from "../../_types/sizing";
@@ -43,6 +42,8 @@
43
42
  icon?: TIconName;
44
43
  }>();
45
44
 
45
+ const slots = useSlots();
46
+
46
47
  const getBadgeSize = computed(()=>{
47
48
  switch (props.size) {
48
49
  case EBadgeSize.MEDIUM:
@@ -18,7 +18,7 @@
18
18
  kind === EButtonTypes.LINK && 'text-accent-alt hover:text-accent-alt-600 active:text-accent-alt-700 disabled:text-accent-alt-300',
19
19
  (!size || size === EButtonSizes.DEFAULT) && 'py-sm px-md',
20
20
  size === EButtonSizes.SMALL && 'py-xs px-md',
21
- size === EButtonSizes.MEDIUM && 'py-xs px-xs',
21
+ size === EButtonSizes.MEDIUM && 'py-sm px-sm',
22
22
  size === EButtonSizes.LARGE && 'py-md px-md',
23
23
  fullWidth && 'w-full',
24
24
  disabled && 'pointer-events-none',
@@ -68,9 +68,8 @@ const Template: Story<TComponentProps> = (args) => ({
68
68
  class="mb-xs"
69
69
  :key="item"
70
70
  :icon="['far', 'face-smile']"
71
- >
72
- Feature item {{ item }}
73
- </ui-list-item>
71
+ :title="'Feature item ' + item"
72
+ />
74
73
  </ul>
75
74
 
76
75
  <ui-typography
@@ -49,7 +49,7 @@ const Template: Story<TComponentProps> = (args) => ({
49
49
  },
50
50
  // And then the `args` are bound to your component with `v-bind="args"`
51
51
  template: `
52
- <ui-checkbox v-bind="args" v-model:modelValue="args.modelValue">
52
+ <ui-checkbox v-bind="args" v-model="modelValue">
53
53
  ${args.slot}
54
54
  </ui-checkbox>
55
55
  `,
@@ -13,11 +13,11 @@
13
13
  ]"
14
14
  >
15
15
  <input
16
- :checked="modelValue"
16
+ v-model="checkboxModel"
17
17
  class="appearance-none absolute"
18
18
  type="checkbox"
19
+ :value="value"
19
20
  :disabled="disabled"
20
- @input="$emit('update:modelValue', !!($event.target as HTMLInputElement)?.value)"
21
21
  >
22
22
  <span
23
23
  class="ui-checkbox_custom w-md h-md flex items-center justify-center border border-secondary-alt-500 rounded relative hover:border-secondary-alt-700"
@@ -50,21 +50,32 @@
50
50
  </template>
51
51
 
52
52
  <script lang="ts" setup>
53
- import { useSlots } from "vue";
53
+ import { useSlots, computed } from "vue";
54
54
  import { EJustify } from "../../_types/align";
55
55
 
56
56
  const slots = useSlots();
57
57
 
58
- defineProps<{
59
- modelValue: boolean;
58
+ const props = defineProps<{
59
+ modelValue: boolean | unknown[];
60
60
  justify?: EJustify;
61
61
  invertOrder?: boolean;
62
62
  disabled?: boolean;
63
+ value?: string;
63
64
  }>();
64
65
 
65
- defineEmits<{
66
- (e: "update:modelValue", state: boolean): void
66
+ const emit = defineEmits<{
67
+ (e: "update:modelValue", state: unknown): void
67
68
  }>();
69
+
70
+ const checkboxModel = computed({
71
+ get() {
72
+ return props.modelValue;
73
+ },
74
+ set(value) {
75
+ emit("update:modelValue", value);
76
+ }
77
+ });
78
+
68
79
  </script>
69
80
 
70
81
  <style scoped>
@@ -1,33 +1,37 @@
1
- import UiIconList from "./ui-list-item.vue";
1
+ import UiListItem from "./ui-list-item.vue";
2
2
  import type { Story } from "@storybook/vue3";
3
3
 
4
4
  export default {
5
5
  title: "Components/ui-list-item",
6
- component: UiIconList,
7
- argTypes: {},
6
+ component: UiListItem,
7
+ argTypes: {
8
+ description: {
9
+ control: { type: "text" },
10
+ title: "The Element title",
11
+ }
12
+ },
8
13
  args: {
9
- slot: "default text",
14
+ slot: "some description text: lorem",
15
+ title: "default text",
10
16
  }
11
17
  };
12
18
 
13
- type TComponentProps = InstanceType<typeof UiIconList>["$props"];
19
+ type TComponentProps = InstanceType<typeof UiListItem>["$props"];
14
20
 
15
21
  const Template: Story<TComponentProps> = (args) => ({
16
- components: { UiIconList },
22
+ components: { UiListItem },
17
23
  setup() {
18
24
  return { args };
19
25
  },
20
26
  template: `
21
- <ul>
22
- <ui-icon-list :icon="['far', 'face-smile']">
23
- {{args.slot}}
24
- </ui-icon-list>
25
- <ui-icon-list :icon="['far', 'face-smile']">
26
- {{args.slot}}
27
- </ui-icon-list>
28
- <ui-icon-list :icon="['far', 'face-smile']">
27
+ <ul class="grid gap-sm">
28
+ <ui-list-item :icon="['far', 'face-smile']" :title="args.title">
29
+ </ui-list-item>
30
+ <ui-list-item :icon="['far', 'face-smile']" :title="args.title">
29
31
  {{args.slot}}
30
- </ui-icon-list>
32
+ </ui-list-item>
33
+ <ui-list-item :icon="['far', 'face-smile']" :title="args.title">
34
+ </ui-list-item>
31
35
  </ul>
32
36
  `
33
37
  });
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <li class="ui-icon-list">
2
+ <li class="ui-icon-list flex">
3
3
  <ui-icon
4
4
  v-if="icon"
5
5
  class="mr-xs"
@@ -7,23 +7,30 @@
7
7
  :icon-name="icon"
8
8
  />
9
9
 
10
- <ui-typography
11
- is="span"
12
- :weight="ETextWeight.SEMI_BOLD"
13
- :size="ETypographySizes.SM"
14
- >
15
- <slot />
16
- </ui-typography>
10
+ <div>
11
+ <ui-typography
12
+ :weight="ETextWeight.SEMI_BOLD"
13
+ >
14
+ {{ title }}
15
+ </ui-typography>
16
+ <p
17
+ v-if="$slots.default"
18
+ class="mt-xs"
19
+ >
20
+ <slot />
21
+ </p>
22
+ </div>
17
23
  </li>
18
24
  </template>
19
25
 
20
26
  <script lang="ts" setup>
21
27
  import UiIcon, { type TIconName } from "../ui-icon";
22
28
  import { ESize } from "../../_types/sizing";
23
- import UiTypography, { ETypographySizes, ETextWeight } from "../ui-typography";
29
+ import UiTypography, { ETextWeight } from "../ui-typography";
24
30
 
25
31
  defineProps<{
26
32
  icon?: TIconName;
33
+ title?: string;
27
34
  }>();
28
35
 
29
36
  </script>
@@ -37,7 +37,7 @@ const Template: Story<TComponentProps> = (args) => ({
37
37
  return { args, modelValue };
38
38
  },
39
39
  template: `
40
- <ui-toggle v-bind="args" v-model:model-value="modelValue" header="Header" :title="args.slot" />
40
+ <ui-toggle v-bind="args" v-model="modelValue" header="Header" :title="args.slot" />
41
41
  `,
42
42
  });
43
43
 
@@ -21,10 +21,10 @@
21
21
  class="ui-input__input-wrapper block relative h-md"
22
22
  >
23
23
  <input
24
+ v-model="checkboxModel"
24
25
  type="checkbox"
25
26
  class="appearance-none absolute w-0 h-0 border-0"
26
- :checked="modelValue"
27
- @input="$emit('update:modelValue', !!($event.target as HTMLInputElement)?.value)"
27
+ :value="value"
28
28
  >
29
29
 
30
30
  <span class="ui-toggle__bg-block w-lg h-md bg-secondary-alt block rounded-full" />
@@ -60,19 +60,30 @@
60
60
 
61
61
  <script lang="ts" setup>
62
62
  import UiTypography, { ETypographySizes, ETextWeight } from "../ui-typography";
63
+ import { computed } from "vue";
63
64
 
64
- defineProps<{
65
+ const props = defineProps<{
65
66
  header?: string;
66
67
  title?: string;
67
- modelValue: boolean;
68
+ modelValue: boolean | unknown[];
68
69
  disabled?: boolean;
69
70
  invertOrder?: boolean;
70
71
  alignCenter?: boolean;
72
+ value?: string;
71
73
  }>();
72
74
 
73
- defineEmits<{
74
- (e: "update:modelValue", state: boolean): void
75
+ const emit = defineEmits<{
76
+ (e: "update:modelValue", state: unknown): void
75
77
  }>();
78
+
79
+ const checkboxModel = computed({
80
+ get() {
81
+ return props.modelValue;
82
+ },
83
+ set(value) {
84
+ emit("update:modelValue", value);
85
+ }
86
+ });
76
87
  </script>
77
88
 
78
89
  <style scoped>