Skip to content

Commit

Permalink
Gradient line variant + fixing types definition for UI components (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
akadlec authored Mar 7, 2022
1 parent 2846b9f commit bbb9c75
Show file tree
Hide file tree
Showing 33 changed files with 337 additions and 189 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fastybird/web-ui-theme",
"version": "0.7.2",
"version": "0.8.0",
"description": "FastyBird basic theme & Vue components for web apps",
"keywords": [
"fastybird",
Expand Down
3 changes: 3 additions & 0 deletions src/assets/components/ui/fb-divider.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@use "sass:math";
@import "../../variables/colors";
@import "../../variables/screen";
@import "../../variables/texts";

Expand All @@ -9,3 +10,5 @@ $divider-size-half: math.ceil(math.div($divider-size, 2)) !default;
$divider-margin: 2rem 0;
$divider-color: #ddd;
$screen-tablet-min: $screen-sm-min;
$screen-gradient-color: $gray-light;
$screen-gradient-bgcolor: transparent;
2 changes: 1 addition & 1 deletion src/components/ui/FbAlert/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FbUiVariantTypes } from "@/types";

export interface IFbUiAlertProps {
variant: FbUiVariantTypes;
variant?: FbUiVariantTypes;
}
24 changes: 12 additions & 12 deletions src/components/ui/FbButton/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import {
} from "@/types";

export interface IFbUiButtonProps {
action: string | { [key: string]: any } | null;
actionType: FbUiButtonActionsTypes;
type: FbUiButtonButtonTypes;
size: FbSizeTypes;
variant: FbUiButtonVariantTypes;
block: boolean;
uppercase: boolean;
pill: boolean;
thick: boolean;
active: boolean;
disabled: boolean;
loading: boolean;
action?: string | { [key: string]: any } | null;
actionType?: FbUiButtonActionsTypes;
type?: FbUiButtonButtonTypes;
size?: FbSizeTypes;
variant?: FbUiButtonVariantTypes;
block?: boolean;
uppercase?: boolean;
pill?: boolean;
thick?: boolean;
active?: boolean;
disabled?: boolean;
loading?: boolean;
}
4 changes: 2 additions & 2 deletions src/components/ui/FbComponentLoading/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FbSizeTypes } from "@/types";

export interface IFbUiComponentLoadingProps {
text: string;
size: FbSizeTypes;
text?: string;
size?: FbSizeTypes;
}
4 changes: 2 additions & 2 deletions src/components/ui/FbComponentLoadingError/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FbSizeTypes } from "@/types";

export interface IFbUiComponentLoadingErrorProps {
text: string;
size: FbSizeTypes;
text?: string;
size?: FbSizeTypes;
}
20 changes: 10 additions & 10 deletions src/components/ui/FbConfirmationWindow/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import {
} from "@/types";

export interface IFbUiConfirmationWindowProps {
size: FbSizeTypes;
primaryButton: FbUiConfirmationWindowPrimaryButtonTypes;
variant: FbUiVariantTypes;
showYes: boolean;
yesBtnLabel: string;
showNo: boolean;
noBtnLabel: string;
enableClosing: boolean;
transparentBg: boolean;
show: boolean;
size?: FbSizeTypes;
primaryButton?: FbUiConfirmationWindowPrimaryButtonTypes;
variant?: FbUiVariantTypes;
showYes?: boolean;
yesBtnLabel?: string;
showNo?: boolean;
noBtnLabel?: string;
enableClosing?: boolean;
transparentBg?: boolean;
show?: boolean;
}
31 changes: 31 additions & 0 deletions src/components/ui/FbDivider/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,37 @@
}
}
}

&[data-variant="gradient"] {
height: 1px;
border: 0;
background: $screen-gradient-color;
background:
-webkit-gradient(
linear,
0 0,
100% 0,
from($screen-gradient-bgcolor),
to($screen-gradient-bgcolor),
color-stop(50%, $screen-gradient-color)
);

&[data-type="vertical"] {
@media (min-width: $screen-tablet-min) {
height: 100%;
width: 1px;
background:
-webkit-gradient(
linear,
0 100%,
0 0,
from($screen-gradient-bgcolor),
to($screen-gradient-bgcolor),
color-stop(50%, $screen-gradient-color)
);
}
}
}
}

&__content {
Expand Down
35 changes: 31 additions & 4 deletions src/components/ui/FbDivider/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
<template>
<hr
v-if="variant === variantTypes.GRADIENT"
:data-type="type"
:data-variant="variant"
class="fb-theme-ui-divider__container"
>

<div
v-else
:data-type="type"
:data-variant="variant"
class="fb-theme-ui-divider__container"
>
<div class="fb-theme-ui-divider__content">
Expand All @@ -15,7 +24,7 @@ import {
PropType,
} from 'vue'
import { FbUiDividerVariantTypes } from '@/types'
import { FbUiDividerTypeTypes, FbUiDividerVariantTypes } from '@/types'
export default defineComponent({
Expand All @@ -24,19 +33,37 @@ export default defineComponent({
props: {
type: {
type: String as PropType<FbUiDividerTypeTypes>,
default: FbUiDividerTypeTypes.HORIZONTAL,
validator: (value: FbUiDividerTypeTypes) => {
// The value must match one of these strings
return [
FbUiDividerTypeTypes.HORIZONTAL,
FbUiDividerTypeTypes.VERTICAL,
].includes(value)
},
},
variant: {
type: String as PropType<FbUiDividerVariantTypes>,
default: FbUiDividerVariantTypes.HORIZONTAL,
default: FbUiDividerVariantTypes.DEFAULT,
validator: (value: FbUiDividerVariantTypes) => {
// The value must match one of these strings
return [
FbUiDividerVariantTypes.HORIZONTAL,
FbUiDividerVariantTypes.VERTICAL,
FbUiDividerVariantTypes.DEFAULT,
FbUiDividerVariantTypes.GRADIENT,
].includes(value)
},
},
},
setup() {
return {
variantTypes: FbUiDividerVariantTypes,
}
},
})
</script>

Expand Down
98 changes: 87 additions & 11 deletions src/components/ui/FbDivider/stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
Story,
} from '@storybook/vue3'

import { FbUiDividerVariantTypes } from '@/types'
import { FbUiDividerTypeTypes, FbUiDividerVariantTypes } from '@/types'

import { IFbUiDividerProps } from './types'
import FbUiDivider from './index.vue'
Expand All @@ -26,15 +26,29 @@ export default {
type: {
type: { name: 'string', required: false },
control: { type: 'select' },
defaultValue: FbUiDividerVariantTypes.HORIZONTAL,
defaultValue: FbUiDividerTypeTypes.HORIZONTAL,
options: [
FbUiDividerVariantTypes.HORIZONTAL,
FbUiDividerVariantTypes.VERTICAL,
FbUiDividerTypeTypes.HORIZONTAL,
FbUiDividerTypeTypes.VERTICAL,
],
description: 'Divider type',
table: {
type: { summary: 'string' },
defaultValue: { summary: FbUiDividerVariantTypes.HORIZONTAL },
defaultValue: { summary: FbUiDividerTypeTypes.HORIZONTAL },
},
},
variant: {
type: { name: 'string', required: false },
control: { type: 'select' },
defaultValue: FbUiDividerVariantTypes.DEFAULT,
options: [
FbUiDividerVariantTypes.DEFAULT,
FbUiDividerVariantTypes.GRADIENT,
],
description: 'Divider variant',
table: {
type: { summary: 'string' },
defaultValue: { summary: FbUiDividerVariantTypes.DEFAULT },
},
},
},
Expand Down Expand Up @@ -77,19 +91,19 @@ export const Horizontal: Story<TemplateArgs> = () => {
<span>Content</span>
</div>
<div style="position: relative;">
<fb-ui-divider type="${FbUiDividerVariantTypes.HORIZONTAL}">AND</fb-ui-divider>
<fb-ui-divider type="${FbUiDividerTypeTypes.HORIZONTAL}">AND</fb-ui-divider>
</div>
<div style="border: 1px solid rgb(221, 221, 221);height: 100px;flex-grow: 2;display: flex;place-content: center;justify-content: center;align-items: center;">
<span>Content</span>
</div>
<div style="position: relative;">
<fb-ui-divider type="${FbUiDividerVariantTypes.HORIZONTAL}">AND</fb-ui-divider>
<fb-ui-divider type="${FbUiDividerTypeTypes.HORIZONTAL}">AND</fb-ui-divider>
</div>
<div style="border: 1px solid rgb(221, 221, 221);height: 100px;flex-grow: 2;display: flex;place-content: center;justify-content: center;align-items: center;">
<span>Content</span>
</div>
<div style="position: relative;">
<fb-ui-divider type="${FbUiDividerVariantTypes.HORIZONTAL}">=</fb-ui-divider>
<fb-ui-divider type="${FbUiDividerTypeTypes.HORIZONTAL}">=</fb-ui-divider>
</div>
<div style="border: 1px solid rgb(221, 221, 221);height: 100px;flex-grow: 2;display: flex;place-content: center;justify-content: center;align-items: center;">
<span>Content</span>
Expand All @@ -108,19 +122,81 @@ export const Vertical: Story<TemplateArgs> = () => {
<span>Content</span>
</div>
<div style="position: relative; width: 50px;">
<fb-ui-divider type="${FbUiDividerVariantTypes.VERTICAL}">OR</fb-ui-divider>
<fb-ui-divider type="${FbUiDividerTypeTypes.VERTICAL}">OR</fb-ui-divider>
</div>
<div style="border: 1px solid rgb(221, 221, 221);height: 100px;flex-grow: 2;display: flex;place-content: center;justify-content: center;align-items: center;">
<span>Content</span>
</div>
<div style="position: relative; width: 50px;">
<fb-ui-divider type="${FbUiDividerTypeTypes.VERTICAL}">OR</fb-ui-divider>
</div>
<div style="border: 1px solid rgb(221, 221, 221);height: 100px;flex-grow: 2;display: flex;place-content: center;justify-content: center;align-items: center;">
<span>Content</span>
</div>
<div style="position: relative; width: 50px;">
<fb-ui-divider type="${FbUiDividerTypeTypes.VERTICAL}">OR</fb-ui-divider>
</div>
<div style="border: 1px solid rgb(221, 221, 221);height: 100px;flex-grow: 2;display: flex;place-content: center;justify-content: center;align-items: center;">
<span>Content</span>
</div>
</div>
`,
}
}

export const GradientHorizontal: Story<TemplateArgs> = () => {
return {
components: { FbUiDivider },
template: `
<div style="display: flex; flex-direction: column;">
<div style="border: 1px solid rgb(221, 221, 221);height: 100px;flex-grow: 2;display: flex;place-content: center;justify-content: center;align-items: center;">
<span>Content</span>
</div>
<div style="position: relative;">
<fb-ui-divider type="${FbUiDividerTypeTypes.HORIZONTAL}" variant="${FbUiDividerVariantTypes.GRADIENT}" />
</div>
<div style="border: 1px solid rgb(221, 221, 221);height: 100px;flex-grow: 2;display: flex;place-content: center;justify-content: center;align-items: center;">
<span>Content</span>
</div>
<div style="position: relative;">
<fb-ui-divider type="${FbUiDividerTypeTypes.HORIZONTAL}" variant="${FbUiDividerVariantTypes.GRADIENT}" />
</div>
<div style="border: 1px solid rgb(221, 221, 221);height: 100px;flex-grow: 2;display: flex;place-content: center;justify-content: center;align-items: center;">
<span>Content</span>
</div>
<div style="position: relative;">
<fb-ui-divider type="${FbUiDividerTypeTypes.HORIZONTAL}" variant="${FbUiDividerVariantTypes.GRADIENT}" />
</div>
<div style="border: 1px solid rgb(221, 221, 221);height: 100px;flex-grow: 2;display: flex;place-content: center;justify-content: center;align-items: center;">
<span>Content</span>
</div>
</div>
`,
}
}

export const GradientVertical: Story<TemplateArgs> = () => {
return {
components: { FbUiDivider },
template: `
<div style="display: flex; flex-direction: row;">
<div style="border: 1px solid rgb(221, 221, 221);height: 100px;flex-grow: 2;display: flex;place-content: center;justify-content: center;align-items: center;">
<span>Content</span>
</div>
<div style="position: relative; width: 50px;">
<fb-ui-divider type="${FbUiDividerTypeTypes.VERTICAL}" variant="${FbUiDividerVariantTypes.GRADIENT}" />
</div>
<div style="border: 1px solid rgb(221, 221, 221);height: 100px;flex-grow: 2;display: flex;place-content: center;justify-content: center;align-items: center;">
<span>Content</span>
</div>
<div style="position: relative; width: 50px;">
<fb-ui-divider type="${FbUiDividerVariantTypes.VERTICAL}">OR</fb-ui-divider>
<fb-ui-divider type="${FbUiDividerTypeTypes.VERTICAL}" variant="${FbUiDividerVariantTypes.GRADIENT}" />
</div>
<div style="border: 1px solid rgb(221, 221, 221);height: 100px;flex-grow: 2;display: flex;place-content: center;justify-content: center;align-items: center;">
<span>Content</span>
</div>
<div style="position: relative; width: 50px;">
<fb-ui-divider type="${FbUiDividerVariantTypes.VERTICAL}">OR</fb-ui-divider>
<fb-ui-divider type="${FbUiDividerTypeTypes.VERTICAL}" variant="${FbUiDividerVariantTypes.GRADIENT}" />
</div>
<div style="border: 1px solid rgb(221, 221, 221);height: 100px;flex-grow: 2;display: flex;place-content: center;justify-content: center;align-items: center;">
<span>Content</span>
Expand Down
8 changes: 6 additions & 2 deletions src/components/ui/FbDivider/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { FbUiDividerVariantTypes } from "@/types";
import {
FbUiDividerTypeTypes,
FbUiDividerVariantTypes,
} from '@/types'

export interface IFbUiDividerProps {
type: FbUiDividerVariantTypes;
type?: FbUiDividerTypeTypes;
variant?: FbUiDividerVariantTypes;
}
4 changes: 2 additions & 2 deletions src/components/ui/FbIconWithChild/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import {
} from "@/types";

export interface IFbUiIconWithChildProps {
variant: FbUiVariantTypes;
size: FbSizeTypes;
variant?: FbUiVariantTypes;
size?: FbSizeTypes;
}
8 changes: 4 additions & 4 deletions src/components/ui/FbLoadingBox/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
} from "@/types";

export interface IFbUiLoadingBoxProps {
fullScreen: boolean;
animation: boolean;
variant: FbUiVariantTypes;
size: FbSizeTypes;
fullScreen?: boolean;
animation?: boolean;
variant?: FbUiVariantTypes;
size?: FbSizeTypes;
}
Loading

0 comments on commit bbb9c75

Please sign in to comment.