Skip to content

Commit

Permalink
docs: add theming section
Browse files Browse the repository at this point in the history
  • Loading branch information
ayZagen committed Feb 23, 2024
1 parent 9aef568 commit 07ce0fa
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 39 deletions.
23 changes: 2 additions & 21 deletions .storybook/global.css
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
.sb-preparing-docs, .sb-nopreview {
@apply hidden
}
.sbdocs{
&.sbdocs-wrapper {
@apply pt-12
}

.hide-controls-column > div > table {
& > thead > tr > th:last-child,
& > tbody > tr:not(:first-child) > td:last-child {
display: none !important;
}

& > thead > tr th:nth-child(1),
& > tbody > tr td:nth-child(1) {
width: 15%;
}

}

input[placeholder="Choose color..."] + svg {
display: none;
}
4 changes: 0 additions & 4 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ const config: StorybookConfig = {
},
async viteFinal(config, {configType}) {
config.publicDir = false
config.plugins = config.plugins?.filter(s => {
return !['vite:lib-inject-css', 'vite:dts'].includes(s!["name"])
}) || []

return config
},
framework: {
Expand Down
22 changes: 22 additions & 0 deletions .storybook/preview.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.sb-preparing-docs, .sb-nopreview {
@apply hidden
}
.sbdocs{
&.sbdocs-wrapper {
@apply pt-12
}

.hide-controls-column > div > table {
& > thead > tr > th:last-child,
& > tbody > tr:not(:first-child) > td:last-child {
display: none !important;
}

& > thead > tr th:nth-child(1),
& > tbody > tr td:nth-child(1) {
width: 15%;
}

}

}
2 changes: 1 addition & 1 deletion .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {Preview} from "@storybook/vue3";
import './global.css'
import './preview.css'

const preview: Preview = {
parameters: {
Expand Down
1 change: 1 addition & 0 deletions .storybook/theme.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { create } from '@storybook/theming/create';
import logoFile from '../stories/public/plusauth-md-dark.svg';
import './global.css'

export default create({
base: 'light',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"storybook": "^8.0.0-beta.4",
"super-tiny-icons": "^0.6.0",
"tailwindcss": "^3.4.1",
"terser": "^5.27.2",
"terser": "^5.28.1",
"ts-jest": "^29.1.2",
"tslib": "^2.6.2",
"typescript": "5.3.3",
Expand Down
24 changes: 12 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions stories/Theming/ThemeStory.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<script setup lang="ts">
import type { AdditionalFields, IWidgetSettings } from '../../src/ui/interfaces';
import WidgetWrapper from '../WidgetWrapper.vue';
const props = defineProps<IWidgetSettings['theme']>()
</script>

<template>
<WidgetWrapper
:context="{
client: {
clientName: 'TestApp',
tosUri: 'https://sometosuri.com',
policyUri: 'https://somepolicyuri.com',
logoUri: 'https://static.plusauth.com/images/logo.png',
social: [
{name: 'google-connection', provider: 'google'},
{name: 'facebook-connection', provider: 'facebook'},
]
},
settings: {
register_enabled: true,
forgot_password_enabled: true,
password_policy: {
min: 4,
max: 16,
lower_case: 4
}
},
} as any"
:settings="{
theme: props,
modeOptions: {
login: {
fields: {
password: {
order: 1,
errors: ['Password is required']
},
otpCode: {
order: 2,
type: 'code',
label: 'OTP'
},
accept: {
order: 3,
type: 'checkbox',
label: 'I accept terms and conditions'
}
}
}
}
}"
/>
</template>
48 changes: 48 additions & 0 deletions stories/Theming/theming.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import type { Meta, StoryObj } from '@storybook/vue3';

import { CustomFields } from '../PageStories/Login/login.stories.ts';

import ThemingStory from './ThemeStory.vue';

type Story = StoryObj<typeof ThemingStory>;

/**
*
*/
const meta: Meta<typeof ThemingStory> = {
component: ThemingStory,
title: 'theming',
}

export default meta


/**
* You can provide custom fields for your view
*/
export const Colors: Story = {
args: {
primary: '#e37006',
secondary: '#424242',
accent: '#82B1FF',
error: '#FF5252',
info: '#2196F3',
success: '#4CAF50',
warning: '#FB8C00',
},
argTypes: [
'primary',
'secondary',
'accent',
'error',
'info',
'success',
'warning'
].reduce((final, type, ) => {
final[type] = {
control: { type: 'color' }
}
return final
}, {})

};

0 comments on commit 07ce0fa

Please sign in to comment.