Skip to content

Commit

Permalink
📝 Add stories for input components (#12)
Browse files Browse the repository at this point in the history
* ➕ Add storybook addon svelte-csf

* ⬆️ Upgrade storybook

* 📝 Add storybook stories for input components

* ♻️ Use prop label for description of inputs

* ♻️ Use prop value for radio group

* 💄 Small style tweaks on input components

* ⏪ Revert "♻️ Use prop value for radio group"

This reverts commit cbd1d1e.

* ♻️ Clean up css and use variables

* ⬆️ Package lock version update

* 🎨 Minor CSS changes
- colors of button border
- added CSS variable for modal header divider color
- added pointer cursor for color input in AOI modification

* ♻️ GeneralButton isDisabled fix
- no dependency of GeneralButtonMajor on processing store
- isDisabled state based on processing store moved to individual PanelButtons

---------

Co-authored-by: misavojte <mich.vojtechovska@gmail.com>
  • Loading branch information
jakoblistabarth and misavojte committed Jan 23, 2024
1 parent 9ebbeda commit 598c1b8
Show file tree
Hide file tree
Showing 47 changed files with 2,044 additions and 533 deletions.
4 changes: 3 additions & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import type { StorybookConfig } from '@storybook/sveltekit'

const config: StorybookConfig = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(ts|tsx)'],
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(ts|tsx|svelte)'],
staticDirs: ['../static'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'@storybook/addon-mdx-gfm',
'@storybook/addon-svelte-csf',
],
framework: {
name: '@storybook/sveltekit',
Expand Down
1,923 changes: 1,543 additions & 380 deletions package-lock.json

Large diffs are not rendered by default.

24 changes: 13 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,17 @@
"svelte": "^4.0.0"
},
"devDependencies": {
"@storybook/addon-essentials": "^7.6.7",
"@storybook/addon-interactions": "^7.6.7",
"@storybook/addon-links": "^7.6.7",
"@storybook/blocks": "^7.6.7",
"@storybook/manager-api": "^7.6.7",
"@storybook/svelte": "^7.6.7",
"@storybook/sveltekit": "^7.6.7",
"@storybook/test": "^7.6.7",
"@storybook/theming": "^7.6.7",
"@storybook/addon-essentials": "^7.6.10",
"@storybook/addon-interactions": "^7.6.10",
"@storybook/addon-links": "^7.6.10",
"@storybook/addon-mdx-gfm": "^7.6.10",
"@storybook/addon-svelte-csf": "^4.1.0",
"@storybook/blocks": "^7.6.10",
"@storybook/manager-api": "^7.6.10",
"@storybook/svelte": "^7.6.10",
"@storybook/sveltekit": "^7.6.10",
"@storybook/test": "^7.6.10",
"@storybook/theming": "^7.6.10",
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/adapter-static": "^3.0.1",
"@sveltejs/kit": "^2.0.0",
Expand All @@ -72,7 +74,7 @@
"publint": "^0.1.9",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"storybook": "^7.6.7",
"storybook": "^7.6.10",
"svelte": "^4.2.7",
"svelte-check": "^3.6.0",
"tslib": "^2.4.1",
Expand All @@ -86,4 +88,4 @@
"dependencies": {
"lucide-svelte": "^0.306.0"
}
}
}
48 changes: 34 additions & 14 deletions src/app.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
html,
body {
margin: 0;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
display: flex;
flex-flow: column;
min-height: 100vh;
}
html,
body {
margin: 0;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
display: flex;
flex-flow: column;
min-height: 100vh;
}

:root {
--c-brand: #cd1404;
--c-brand-dark: #a20d03;
--c-white: #ffffff;
--c-darkwhite: #f3f3f5;
--c-lightgrey: #ebebef;
--c-grey: #e4e4e9;
--c-midgrey: #d9d9d9;
--c-darkgrey: #888888;
--c-black: #202020;

--c-error: #ff4d4f;
--c-success: #22c55e;
--c-warning: #faad14;
--c-info: #1890ff;

--rounded: 4px;
--rounded-md: 8px;
--rounded-lg: 20px;
}
9 changes: 0 additions & 9 deletions src/lib/components/GazePlotter.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,6 @@
</div>

<style>
:global(:root) {
--c-brand: #cd1404;
--c-brand-dark: #a20d03;
--c-white: #fff;
--c-darkwhite: #f3f3f5;
--c-lightgrey: #ebebef;
--c-darkgrey: #e4e4e9;
--c-black: rgba(0, 0, 0, 0.75);
}
#GP-gazeplotter {
font-family: inherit;
font-size: 16px;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<script context="module" lang="ts">
import GeneralButtonMajor from './GeneralButtonMajor.svelte'
export const meta = {
title: 'Inputs/GeneralButtonMajor',
component: GeneralButtonMajor,
tags: ['autodocs'],
}
</script>

<script>
import { Story, Template } from '@storybook/addon-svelte-csf'
</script>

<Template let:args>
<GeneralButtonMajor {...args}>Primary Button</GeneralButtonMajor>
</Template>

<Story name="Default" />

<Story name="Disabled" args={{ isDisabled: true }} />
18 changes: 6 additions & 12 deletions src/lib/components/General/GeneralButton/GeneralButtonMajor.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
<script lang="ts">
import { processingFileStateStore } from '$lib/stores/processingFileStateStore.js'
export let isDisabled = false
processingFileStateStore.subscribe(isProcessingFile => {
isDisabled = isProcessingFile === 'processing'
})
</script>

<button disabled={isDisabled} on:click>
Expand All @@ -14,11 +8,11 @@

<style>
button {
background-color: #ebebef;
background-color: var(--c-lightgrey);
border: none;
color: var(--c-black);
padding: 10px 20px;
border-radius: 20px;
padding: 0.75em 1.5em;
border-radius: var(--rounded-lg);
text-align: center;
text-decoration: none;
display: inline-block;
Expand All @@ -27,11 +21,11 @@
font-weight: 600;
}
button:hover {
background-color: #e4e4e9;
background-color: var(--c-grey);
}
button:disabled {
background-color: #cccccc;
color: #666666;
color: var(--c-midgrey);
background-color: var(--c-lightgrey);
cursor: not-allowed;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@
position: absolute;
top: calc(100% + 5px);
right: 0;
background: #fff;
background: var(--c-white);
border: 1px solid #ccc;
border-radius: 4px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
border-radius: var(--rounded);
box-shadow: 0 0 10px var(--c-grey);
overflow: hidden;
}
.menu,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<script context="module" lang="ts">
import GeneralButtonMinor from './GeneralButtonMinor.svelte'
export const meta = {
title: 'Inputs/GeneralButtonMinor',
component: GeneralButtonMinor,
tags: ['autodocs'],
}
</script>

<script>
import { Story, Template } from '@storybook/addon-svelte-csf'
import User from 'lucide-svelte/icons/user'
</script>

<Template let:args>
<GeneralButtonMinor {...args}><User /></GeneralButtonMinor>
</Template>

<Story name="Default" />

<!-- TODO: find out why this is not working here but workin for minor button -->
<Story name="Disabled" args={{ isDisabled: true }} />

<Story name="with Text">
<GeneralButtonMinor isIcon={false}>Minor Button</GeneralButtonMinor>
</Story>
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<style>
button {
background: none;
border: 1px solid rgba(0, 0, 0, 0.23);
border-radius: 4px;
color: rgba(0, 0, 0, 0.7);
border: 1px solid var(--c-darkgrey);
border-radius: var(--rounded);
color: var(--c-black);
padding: 0.25em 0.5em;
text-align: center;
text-decoration: none;
Expand All @@ -35,12 +35,12 @@
width: 34px;
}
button:hover {
border: 1px solid #cd1404;
color: #cd1404;
border: 1px solid var(--c-brand);
color: var(--c-brand);
}
button:disabled {
cursor: not-allowed;
color: rgba(0, 0, 0, 0.26);
border: 1px solid rgba(0, 0, 0, 0.12);
color: var(--c-darkgrey);
border: 1px solid var(--c-midgrey);
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<script context="module" lang="ts">
import GeneralEmpty from './GeneralEmpty.svelte'
export const meta = {
title: 'Inputs/GeneralEmpty',
component: GeneralEmpty,
tags: ['autodocs'],
args: {
message: 'This is a default empty message.',
},
}
</script>

<script>
import { Story, Template } from '@storybook/addon-svelte-csf'
</script>

<Template let:args>
<GeneralEmpty {...args} />
</Template>

<Story name="Default" />
<Story
name="Long empty text"
args={{
message:
'Case felt the edge of the room where Case waited. It was disturbing to think of the Flatline as a gliding cursor struck sparks from the missionaries.',
}}
/>
6 changes: 3 additions & 3 deletions src/lib/components/General/GeneralEmpty/GeneralEmpty.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<style>
.empty {
padding: 1em;
border: 1px solid #ebebef;
border-radius: 3px;
color: gray;
border: 1px solid var(--c-lightgrey);
border-radius: var(--rounded);
color: var(--c-darkgrey);
display: flex;
align-items: center;
justify-content: center;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<script context="module" lang="ts">
import GeneralInputNumber from '../GeneralInput/GeneralInputNumber.svelte'
import GeneralRadio from '../GeneralRadio/GeneralRadio.svelte'
import GeneralFieldset from './GeneralFieldset.svelte'
export const meta = {
title: 'Inputs/GeneralFieldset',
component: GeneralFieldset,
tags: ['autodocs'],
args: {
legend: 'legend label',
},
}
</script>

<script>
import { Story, Template } from '@storybook/addon-svelte-csf'
</script>

<Template let:args>
<GeneralFieldset {...args}>
<GeneralInputNumber label="A number input" />
<GeneralRadio
options={[
{ value: 'this_stimulus', label: 'This stimulus' },
{ value: 'all_stimuli', label: 'All stimuli' },
]}
legend="A radio input"
/>
</GeneralFieldset>
</Template>

<Story name="Default" />
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

<style>
fieldset {
border: 1px solid #ccc;
border: 1px solid var(--c-darkgrey);
border-radius: var(--rounded);
padding: 10px;
margin-bottom: 20px;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script context="module" lang="ts">
import GeneralInputCheck from './GeneralInputCheck.svelte'
export const meta = {
title: 'Inputs/GeneralInputCheck',
component: GeneralInputCheck,
tags: ['autodocs'],
args: {
label: 'I ❤️ scarfplots label',
},
}
</script>

<script>
import { Story, Template } from '@storybook/addon-svelte-csf'
</script>

<Template let:args>
<GeneralInputCheck {...args} />
</Template>

<Story name="Default" />
<Story name="Checked" args={{ ...meta.args, checked: true }} />
Loading

0 comments on commit 598c1b8

Please sign in to comment.