@lism-css/ui 0.11.0 → 0.12.0
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/README.md +1 -1
- package/dist/components/Accordion/Accordion.stories.d.ts +7 -0
- package/dist/components/Accordion/getProps.d.ts +55 -42
- package/dist/components/Accordion/getProps.js +36 -32
- package/dist/components/Accordion/react/AccIcon.d.ts +2 -1
- package/dist/components/Accordion/react/Accordion.d.ts +12 -21
- package/dist/components/Accordion/react/Accordion.js +30 -29
- package/dist/components/Accordion/react/index.d.ts +10 -11
- package/dist/components/Accordion/setAccordion.d.ts +6 -3
- package/dist/components/Accordion/setAccordion.js +12 -10
- package/dist/components/Alert/Alert.stories.d.ts +13 -0
- package/dist/components/Alert/getProps.d.ts +6 -4
- package/dist/components/Alert/react/Alert.d.ts +3 -4
- package/dist/components/Alert/react/Alert.js +2 -2
- package/dist/components/Avatar/Avatar.stories.d.ts +8 -0
- package/dist/components/Avatar/react/Avatar.d.ts +10 -6
- package/dist/components/Avatar/react/Avatar.js +1 -1
- package/dist/components/Badge/Badge.stories.d.ts +8 -0
- package/dist/components/Badge/react/Badge.d.ts +3 -1
- package/dist/components/Badge/react/Badge.js +5 -8
- package/dist/components/Button/Button.stories.d.ts +8 -0
- package/dist/components/Button/react/Button.d.ts +3 -1
- package/dist/components/Button/react/Button.js +3 -6
- package/dist/components/Callout/Callout.stories.d.ts +12 -0
- package/dist/components/Callout/getProps.d.ts +3 -2
- package/dist/components/Callout/react/Callout.d.ts +3 -4
- package/dist/components/Callout/react/Callout.js +4 -4
- package/dist/components/Chat/Chat.stories.d.ts +9 -0
- package/dist/components/Chat/getProps.d.ts +43 -44
- package/dist/components/Chat/getProps.js +2 -2
- package/dist/components/Chat/react/Chat.d.ts +11 -7
- package/dist/components/Chat/react/Chat.js +10 -10
- package/dist/components/Details/Details.stories.d.ts +6 -0
- package/dist/components/Details/getProps.d.ts +34 -35
- package/dist/components/Details/getProps.js +16 -6
- package/dist/components/Details/react/Details.d.ts +11 -20
- package/dist/components/Details/react/Details.js +15 -15
- package/dist/components/Details/react/index.d.ts +7 -7
- package/dist/components/DummyImage/DummyImage.stories.d.ts +7 -0
- package/dist/components/DummyText/DummyText.stories.d.ts +9 -0
- package/dist/components/Modal/Modal.stories.d.ts +6 -0
- package/dist/components/Modal/getProps.d.ts +36 -36
- package/dist/components/Modal/getProps.js +36 -17
- package/dist/components/Modal/react/Body.d.ts +2 -4
- package/dist/components/Modal/react/CloseBtn.d.ts +9 -7
- package/dist/components/Modal/react/CloseBtn.js +5 -5
- package/dist/components/Modal/react/Inner.d.ts +3 -4
- package/dist/components/Modal/react/Modal.d.ts +4 -4
- package/dist/components/Modal/react/Modal.js +11 -9
- package/dist/components/Modal/react/OpenBtn.d.ts +7 -5
- package/dist/components/Modal/react/OpenBtn.js +4 -4
- package/dist/components/Modal/react/index.d.ts +7 -8
- package/dist/components/NavMenu/NavMenu.stories.d.ts +7 -0
- package/dist/components/NavMenu/getProps.d.ts +31 -29
- package/dist/components/NavMenu/react/NavMenu.d.ts +6 -16
- package/dist/components/NavMenu/react/NavMenu.js +21 -17
- package/dist/components/NavMenu/react/index.d.ts +6 -6
- package/dist/components/ShapeDivider/ShapeDivider.stories.d.ts +10 -0
- package/dist/components/ShapeDivider/getProps.d.ts +16 -11
- package/dist/components/ShapeDivider/getProps.js +10 -12
- package/dist/components/ShapeDivider/react/ShapeDivider.d.ts +3 -4
- package/dist/components/ShapeDivider/react/ShapeDivider.js +3 -3
- package/dist/components/Tabs/Tabs.stories.d.ts +6 -0
- package/dist/components/Tabs/getProps.d.ts +11 -4
- package/dist/components/Tabs/getProps.js +14 -4
- package/dist/components/Tabs/react/Tab.d.ts +8 -6
- package/dist/components/Tabs/react/Tab.js +15 -6
- package/dist/components/Tabs/react/TabItem.d.ts +7 -4
- package/dist/components/Tabs/react/TabList.d.ts +2 -1
- package/dist/components/Tabs/react/TabPanel.d.ts +8 -6
- package/dist/components/Tabs/react/Tabs.d.ts +9 -7
- package/dist/components/Tabs/react/Tabs.js +50 -36
- package/dist/components/Tabs/react/index.d.ts +8 -8
- package/dist/components/Tabs/setTabs.d.ts +1 -1
- package/dist/components/Tabs/setTabs.js +25 -15
- package/dist/lism-css/dist/components/{Center → layout/Center}/index.js +1 -1
- package/dist/lism-css/dist/components/{Flex → layout/Flex}/index.js +1 -1
- package/dist/lism-css/dist/components/{Flow → layout/Flow}/index.js +1 -1
- package/dist/lism-css/dist/components/{Frame → layout/Frame}/index.js +1 -1
- package/dist/lism-css/dist/components/{Grid → layout/Grid}/index.js +1 -1
- package/dist/lism-css/dist/components/{Stack → layout/Stack}/index.js +1 -1
- package/dist/lism-css/dist/config/defaults/props.js +16 -26
- package/dist/lism-css/dist/config/defaults/states.js +3 -23
- package/dist/lism-css/dist/lib/getLayoutProps.js +6 -9
- package/dist/lism-css/dist/lib/getLismProps.js +94 -92
- package/dist/lism-css/dist/lib/helper/mergeSet.js +14 -0
- package/dist/style.css +1 -1
- package/dist/ui.css +1 -1
- package/package.json +14 -7
- package/src/components/Accordion/Accordion.stories.tsx +105 -0
- package/src/components/Accordion/astro/Button.astro +2 -2
- package/src/components/Accordion/getProps.ts +91 -0
- package/src/components/Accordion/react/{AccIcon.jsx → AccIcon.tsx} +2 -2
- package/src/components/Accordion/react/{Accordion.jsx → Accordion.tsx} +33 -11
- package/src/components/Accordion/setAccordion.ts +120 -0
- package/src/components/Alert/Alert.stories.tsx +64 -0
- package/src/components/Alert/getProps.ts +5 -3
- package/src/components/Alert/react/Alert.tsx +3 -3
- package/src/components/Avatar/Avatar.stories.tsx +42 -0
- package/src/components/Avatar/react/Avatar.tsx +17 -0
- package/src/components/Badge/Badge.stories.tsx +40 -0
- package/src/components/Badge/astro/Badge.astro +1 -7
- package/src/components/Badge/react/Badge.tsx +7 -0
- package/src/components/Button/Button.stories.tsx +44 -0
- package/src/components/Button/astro/Button.astro +1 -7
- package/src/components/Button/react/Button.tsx +7 -0
- package/src/components/Callout/Callout.stories.tsx +55 -0
- package/src/components/Callout/getProps.ts +3 -2
- package/src/components/Callout/react/Callout.tsx +3 -3
- package/src/components/Chat/Chat.stories.tsx +58 -0
- package/src/components/Chat/_style.css +5 -5
- package/src/components/Chat/{getProps.js → getProps.ts} +10 -4
- package/src/components/Chat/react/{Chat.jsx → Chat.tsx} +13 -3
- package/src/components/Details/Details.stories.tsx +61 -0
- package/src/components/Details/astro/Title.astro +2 -2
- package/src/components/Details/{getProps.js → getProps.ts} +19 -6
- package/src/components/Details/react/Details.tsx +69 -0
- package/src/components/DummyImage/DummyImage.stories.tsx +23 -0
- package/src/components/DummyText/DummyText.stories.tsx +48 -0
- package/src/components/Modal/Modal.stories.tsx +67 -0
- package/src/components/Modal/astro/CloseBtn.astro +2 -2
- package/src/components/Modal/astro/OpenBtn.astro +2 -3
- package/src/components/Modal/getProps.ts +65 -0
- package/src/components/Modal/react/Body.tsx +10 -0
- package/src/components/Modal/react/CloseBtn.tsx +24 -0
- package/src/components/Modal/react/Inner.tsx +6 -0
- package/src/components/Modal/react/Modal.tsx +24 -0
- package/src/components/Modal/react/OpenBtn.tsx +15 -0
- package/src/components/Modal/{script.js → script.ts} +1 -1
- package/src/components/NavMenu/NavMenu.stories.tsx +68 -0
- package/src/components/NavMenu/getProps.ts +60 -0
- package/src/components/NavMenu/react/NavMenu.tsx +40 -0
- package/src/components/ShapeDivider/ShapeDivider.stories.tsx +87 -0
- package/src/components/ShapeDivider/getProps.ts +36 -0
- package/src/components/ShapeDivider/react/{ShapeDivider.jsx → ShapeDivider.tsx} +4 -4
- package/src/components/Tabs/Tabs.stories.tsx +79 -0
- package/src/components/Tabs/astro/Tab.astro +2 -1
- package/src/components/Tabs/astro/{transformTabitems.js → transformTabitems.ts} +9 -9
- package/src/components/Tabs/getProps.ts +23 -0
- package/src/components/Tabs/react/Tab.tsx +21 -0
- package/src/components/Tabs/react/TabItem.tsx +13 -0
- package/src/components/Tabs/react/TabList.tsx +5 -0
- package/src/components/Tabs/react/{TabPanel.jsx → TabPanel.tsx} +8 -3
- package/src/components/Tabs/react/{Tabs.jsx → Tabs.tsx} +27 -12
- package/src/components/Tabs/{script.js → script.ts} +2 -2
- package/src/components/Tabs/setTabs.ts +65 -0
- package/src/helper/{uuid.js → uuid.ts} +2 -2
- package/src/vite-env.d.ts +1 -0
- package/dist/components/Accordion/astro/__setEvent.d.ts +0 -1
- package/dist/components/Accordion/astro/index.d.ts +0 -15
- package/dist/components/Alert/astro/index.d.ts +0 -1
- package/dist/components/Callout/astro/index.d.ts +0 -1
- package/dist/components/Details/astro/index.d.ts +0 -13
- package/dist/components/DummyImage/astro/index.d.ts +0 -1
- package/dist/components/DummyText/astro/index.d.ts +0 -1
- package/dist/components/Modal/astro/index.d.ts +0 -13
- package/dist/components/NavMenu/astro/index.d.ts +0 -11
- package/dist/components/Tabs/astro/index.d.ts +0 -13
- package/dist/components/Tabs/astro/transformTabitems.d.ts +0 -4
- package/dist/components/astro.d.ts +0 -14
- package/dist/lism-css/dist/config/helper/getSvgUrl.js +0 -4
- package/src/components/Accordion/getProps.js +0 -77
- package/src/components/Accordion/setAccordion.js +0 -146
- package/src/components/Avatar/astro/index.js +0 -1
- package/src/components/Avatar/react/Avatar.jsx +0 -9
- package/src/components/Badge/astro/index.js +0 -1
- package/src/components/Badge/react/Badge.jsx +0 -12
- package/src/components/Button/astro/index.js +0 -1
- package/src/components/Button/react/Button.jsx +0 -12
- package/src/components/Chat/astro/index.js +0 -1
- package/src/components/Details/react/Details.jsx +0 -66
- package/src/components/Modal/getProps.js +0 -30
- package/src/components/Modal/react/Body.jsx +0 -10
- package/src/components/Modal/react/CloseBtn.jsx +0 -20
- package/src/components/Modal/react/Inner.jsx +0 -6
- package/src/components/Modal/react/Modal.jsx +0 -23
- package/src/components/Modal/react/OpenBtn.jsx +0 -11
- package/src/components/NavMenu/getProps.js +0 -65
- package/src/components/NavMenu/react/NavMenu.jsx +0 -19
- package/src/components/ShapeDivider/astro/index.js +0 -1
- package/src/components/ShapeDivider/getProps.js +0 -40
- package/src/components/Tabs/getProps.js +0 -8
- package/src/components/Tabs/react/Tab.jsx +0 -10
- package/src/components/Tabs/react/TabItem.jsx +0 -5
- package/src/components/Tabs/react/TabList.jsx +0 -6
- package/src/components/Tabs/setTabs.js +0 -87
- /package/src/components/Accordion/astro/{index.js → index.ts} +0 -0
- /package/src/components/Accordion/react/{index.js → index.ts} +0 -0
- /package/src/components/Accordion/{script.js → script.ts} +0 -0
- /package/{dist/components/Avatar/astro/index.d.ts → src/components/Avatar/astro/index.ts} +0 -0
- /package/src/components/Avatar/react/{index.js → index.ts} +0 -0
- /package/{dist/components/Badge/astro/index.d.ts → src/components/Badge/astro/index.ts} +0 -0
- /package/src/components/Badge/react/{index.js → index.ts} +0 -0
- /package/{dist/components/Button/astro/index.d.ts → src/components/Button/astro/index.ts} +0 -0
- /package/src/components/Button/react/{index.js → index.ts} +0 -0
- /package/{dist/components/Chat/astro/index.d.ts → src/components/Chat/astro/index.ts} +0 -0
- /package/src/components/Chat/react/{index.js → index.ts} +0 -0
- /package/src/components/Details/astro/{index.js → index.ts} +0 -0
- /package/src/components/Details/react/{index.js → index.ts} +0 -0
- /package/src/components/Modal/astro/{index.js → index.ts} +0 -0
- /package/src/components/Modal/react/{index.js → index.ts} +0 -0
- /package/src/components/NavMenu/astro/{index.js → index.ts} +0 -0
- /package/src/components/NavMenu/react/{index.js → index.ts} +0 -0
- /package/{dist/components/ShapeDivider/astro/index.d.ts → src/components/ShapeDivider/astro/index.ts} +0 -0
- /package/src/components/ShapeDivider/react/{index.js → index.ts} +0 -0
- /package/src/components/Tabs/astro/{index.js → index.ts} +0 -0
- /package/src/components/Tabs/react/{index.js → index.ts} +0 -0
package/dist/ui.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer lism-modules{.c--accordion{--duration: var(--acc-duration, .25s)}.c--accordion_item{--_panel-h: 0px;--_icon-transform: rotate(0deg)}.c--accordion_item[data-opened]{--_icon-transform: rotate(90deg);--_panel-h: auto}.c--accordion_panel{height:var(--_panel-h);transition:height var(--duration)}[hidden]>.c--accordion_content{position:absolute}.c--accordion_icon{display:grid;width:1em;height:1em}.c--accordion_icon:before,.c--accordion_icon:after{content:"";display:block;grid-area:1 / 1;background-color:currentColor}.c--accordion_icon:before{width:.1em;height:100%;transition:transform var(--duration);transform:var(--_icon-transform)}.c--accordion_icon:after{height:.1em;width:100%}.c--accordion_button:focus-visible{outline:solid 2px currentColor;outline-color:revert;outline-offset:-3px}@media(prefers-reduced-motion:reduce){.c--accordion_item{--duration: 0s}}@media(scripting:none){.c--accordion_panel{height:auto!important;content-visibility:visible!important}.c--accordion_content{position:static!important}}}@layer lism-modules{.c--details{--duration: var(--acc-duration, .25s);--_icon-scale: 1.1;--_icon-transform: rotate(0deg);--_content-gtr: 0fr}.c--details[open]{--_icon-transform: scaleY(-1);--_content-gtr: 1fr}.c--details_summary::-webkit-details-marker{display:none}.c--details_icon{--svg: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" width="1em" height="1em" fill="currentColor"><path d="M216.49,104.49l-80,80a12,12,0,0,1-17,0l-80-80a12,12,0,0,1,17-17L128,159l71.51-71.52a12,12,0,0,1,17,17Z"></path></svg>');display:inline-grid;background-color:currentColor;-webkit-mask:var(--svg) no-repeat center center / contain;mask:var(--svg) no-repeat center center / contain;scale:var(--_icon-scale);transition:transform var(--duration);transform:var(--_icon-transform)}.c--details::details-content{display:grid;grid-template-rows:var(--_content-gtr);transition-duration:var(--duration);transition-property:content-visibility,grid-template;transition-behavior:allow-discrete}.c--details_body{overflow:hidden}}@layer lism-modules{.c--modal{--flow: 0;--duration: var(--modal-duration, .4s);width:100%;height:100%;max-width:100%;max-height:100%;overflow:unset;background:var(--backdrop-bg, rgb(0 0 0 / .6));transition-duration:var(--duration);transition-property:opacity}.c--modal::backdrop{background:none}.c--modal[open]{display:flex;flex-direction:column;justify-content:center}.c--modal_inner{--offset: 0 0;background-color:var(--base);transition:translate var(--duration);max-height:100%}.c--modal:not([data-is-open]){opacity:0}.c--modal:not([data-is-open])>.c--modal_inner{translate:var(--offset)}}@layer lism-modules{.c--navMenu{--link-td: none;--hl: var(--hl--s);--_item-p: var(--s20);--focus-offset: -1px}.c--navMenu_nest{--_item-p: inherit}.c--navMenu_link{padding:var(--_item-p)}.c--navMenu_nest,.c--navMenu_item{--bdc: inherit}}@layer lism-modules{.c--tabs{display:grid;grid:"list" "panel" / 100%}.c--tabs_list{grid-area:list;display:flex;overflow-x:auto}.c--tabs_tab[aria-selected=true]{--_notSelected: }.c--tabs_tab[aria-selected=false]{--_isSelected: }:where(.c--tabs_tab){color:var(--_notSelected, var(--text-2))}.c--tabs_panel{grid-area:panel;width:100%}.c--tabs_panel:where([aria-hidden=true]){display:none}}@layer lism-modules{.c--badge{--c: var(--base);--bgc: var(--text);--bdc: transparent;color:var(--c);background-color:var(--bgc);border:solid 1px var(--bdc)}.c--badge--outline{--c: var(--text);--bgc: transparent;--bdc: currentColor}}@layer lism-modules{.c--button{--c: var(--base);--bgc: var(--text);--bdc: var(--bgc);color:var(--c);background-color:var(--bgc);border:solid 1px var(--bdc);gap:var(--s10);text-decoration:none;place-content:center;place-items:center}.c--button--outline{--c: var(--text);--bgc: transparent;--bdc: var(--c)}:where(.c--button)>.a--icon{scale:1.05}.c--button:where(.l--grid){grid-template-columns:minmax(1em,auto) 1fr minmax(1em,auto);justify-items:center}.c--button:where(.l--grid)>:not(.a--icon){grid-column:2}}@layer lism-modules{.c--chat{--cbox-bgPct: 8
|
|
1
|
+
@layer lism-modules{.c--accordion{--duration: var(--acc-duration, .25s)}.c--accordion_item{--_panel-h: 0px;--_icon-transform: rotate(0deg)}.c--accordion_item[data-opened]{--_icon-transform: rotate(90deg);--_panel-h: auto}.c--accordion_panel{height:var(--_panel-h);transition:height var(--duration)}[hidden]>.c--accordion_content{position:absolute}.c--accordion_icon{display:grid;width:1em;height:1em}.c--accordion_icon:before,.c--accordion_icon:after{content:"";display:block;grid-area:1 / 1;background-color:currentColor}.c--accordion_icon:before{width:.1em;height:100%;transition:transform var(--duration);transform:var(--_icon-transform)}.c--accordion_icon:after{height:.1em;width:100%}.c--accordion_button:focus-visible{outline:solid 2px currentColor;outline-color:revert;outline-offset:-3px}@media(prefers-reduced-motion:reduce){.c--accordion_item{--duration: 0s}}@media(scripting:none){.c--accordion_panel{height:auto!important;content-visibility:visible!important}.c--accordion_content{position:static!important}}}@layer lism-modules{.c--details{--duration: var(--acc-duration, .25s);--_icon-scale: 1.1;--_icon-transform: rotate(0deg);--_content-gtr: 0fr}.c--details[open]{--_icon-transform: scaleY(-1);--_content-gtr: 1fr}.c--details_summary::-webkit-details-marker{display:none}.c--details_icon{--svg: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" width="1em" height="1em" fill="currentColor"><path d="M216.49,104.49l-80,80a12,12,0,0,1-17,0l-80-80a12,12,0,0,1,17-17L128,159l71.51-71.52a12,12,0,0,1,17,17Z"></path></svg>');display:inline-grid;background-color:currentColor;-webkit-mask:var(--svg) no-repeat center center / contain;mask:var(--svg) no-repeat center center / contain;scale:var(--_icon-scale);transition:transform var(--duration);transform:var(--_icon-transform)}.c--details::details-content{display:grid;grid-template-rows:var(--_content-gtr);transition-duration:var(--duration);transition-property:content-visibility,grid-template;transition-behavior:allow-discrete}.c--details_body{overflow:hidden}}@layer lism-modules{.c--modal{--flow: 0;--duration: var(--modal-duration, .4s);width:100%;height:100%;max-width:100%;max-height:100%;overflow:unset;background:var(--backdrop-bg, rgb(0 0 0 / .6));transition-duration:var(--duration);transition-property:opacity}.c--modal::backdrop{background:none}.c--modal[open]{display:flex;flex-direction:column;justify-content:center}.c--modal_inner{--offset: 0 0;background-color:var(--base);transition:translate var(--duration);max-height:100%}.c--modal:not([data-is-open]){opacity:0}.c--modal:not([data-is-open])>.c--modal_inner{translate:var(--offset)}}@layer lism-modules{.c--navMenu{--link-td: none;--hl: var(--hl--s);--_item-p: var(--s20);--focus-offset: -1px}.c--navMenu_nest{--_item-p: inherit}.c--navMenu_link{padding:var(--_item-p)}.c--navMenu_nest,.c--navMenu_item{--bdc: inherit}}@layer lism-modules{.c--tabs{display:grid;grid:"list" "panel" / 100%}.c--tabs_list{grid-area:list;display:flex;overflow-x:auto}.c--tabs_tab[aria-selected=true]{--_notSelected: }.c--tabs_tab[aria-selected=false]{--_isSelected: }:where(.c--tabs_tab){color:var(--_notSelected, var(--text-2))}.c--tabs_panel{grid-area:panel;width:100%}.c--tabs_panel:where([aria-hidden=true]){display:none}}@layer lism-modules{.c--badge{--c: var(--base);--bgc: var(--text);--bdc: transparent;color:var(--c);background-color:var(--bgc);border:solid 1px var(--bdc)}.c--badge--outline{--c: var(--text);--bgc: transparent;--bdc: currentColor}}@layer lism-modules{.c--button{--c: var(--base);--bgc: var(--text);--bdc: var(--bgc);color:var(--c);background-color:var(--bgc);border:solid 1px var(--bdc);gap:var(--s10);text-decoration:none;place-content:center;place-items:center}.c--button--outline{--c: var(--text);--bgc: transparent;--bdc: var(--c)}:where(.c--button)>.a--icon{scale:1.05}.c--button:where(.l--grid){grid-template-columns:minmax(1em,auto) 1fr minmax(1em,auto);justify-items:center}.c--button:where(.l--grid)>:not(.a--icon){grid-column:2}}@layer lism-modules{.c--chat{--cbox-bgPct: 8%;grid-template-areas:"avatar name" "avatar body";grid-template-columns:auto 1fr;grid-template-rows:minmax(1.5rem,auto) auto;--_avator-size: clamp(48px, 32px + 5cqw, 64px);--_deco-size: calc(min(var(--_avator-size), 80px)/4 + .25rem) ;--_deco-mask: none;--_deco-t: 0;--_deco-scale: 1;--_deco-inset-x: 0;gap:0 calc(var(--_deco-size) + 1px)}.c--chat_avatar{grid-area:avatar;width:var(--_avator-size)}.c--chat_name{grid-area:name}.c--chat_body{grid-area:body}.c--chat_content{max-width:var(--sz--s)}.c--chat_deco{top:var(--_deco-t);inset-inline:var(--_deco-inset-x);width:var(--_deco-size);height:var(--_deco-size);scale:var(--_deco-scale);-webkit-mask:var(--_deco-mask) center / contain no-repeat;mask:var(--_deco-mask) center / contain no-repeat}.c--chat--speak{--_deco-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8"><path d="M8,8L8,8C7.4,4.8,5.4,2,2.6,0.4L2,0h6V8z"/></svg>')}[data-chat-dir=start]{--_deco-inset-x: auto calc(100% - 1px) }[data-chat-dir=end]{--_deco-scale: -1 1;--_deco-inset-x: calc(100% - 1px) auto;grid-template-areas:"name avatar" "body avatar";grid-template-columns:1fr auto}}.c--chat--speak[data-chat-dir=start]>div>.c--chat_content{border-start-start-radius:0}.c--chat--speak[data-chat-dir=end]>div>.c--chat_content{border-start-end-radius:0}@layer lism-modules{.c--shapeDivider{--level: 0;--_inner-offset: 0px;--_inner-stretch: 1;--_flipX: 1;--_flipY: 1;height:clamp(calc(5px * var(--level)),calc(1cqw * var(--level)),calc(12px * var(--level)));overflow:visible}.c--shapeDivider:where([data-flip^=X]){--_flipX: -1}.c--shapeDivider:where([data-flip$=Y]){--_flipY: -1}.c--shapeDivider_inner{--offsetY: .5px;--offsetX: -.5px;height:100%;width:calc(100% + 1px);scale:calc(var(--_flipX) * var(--_inner-stretch)) var(--_flipY);translate:calc(var(--offsetX) + var(--_inner-offset)) calc(var(--offsetY) * var(--_flipY))}.c--shapeDivider_svg{display:block}:where([data-has-animation=true]) .c--shapeDivider_svg{transform-origin:100% 0;animation:lism--slideShape 12s infinite alternate linear}}@keyframes lism--slideShape{0%{transform:scaleX(4)}to{transform:scaleX(4) translate(75%)}}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lism-css/ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "UI components by
|
|
3
|
+
"version": "0.12.0",
|
|
4
|
+
"description": "UI components for React and Astro, powered by Lism CSS.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "ddryo",
|
|
7
7
|
"url": "https://github.com/ddryo"
|
|
@@ -21,11 +21,10 @@
|
|
|
21
21
|
"exports": {
|
|
22
22
|
"./react": {
|
|
23
23
|
"import": "./dist/components/react.js",
|
|
24
|
-
"types": "./dist/components/
|
|
24
|
+
"types": "./dist/components/react.d.ts"
|
|
25
25
|
},
|
|
26
26
|
"./astro": {
|
|
27
|
-
"import": "./src/components/astro.
|
|
28
|
-
"types": "./dist/components/index.d.ts"
|
|
27
|
+
"import": "./src/components/astro.ts"
|
|
29
28
|
},
|
|
30
29
|
"./scripts/*": "./dist/scripts/*.js",
|
|
31
30
|
"./style.css": "./dist/style.css"
|
|
@@ -39,9 +38,13 @@
|
|
|
39
38
|
"url": "https://github.com/lism-css/lism-css/issues"
|
|
40
39
|
},
|
|
41
40
|
"dependencies": {
|
|
42
|
-
"lism-css": "0.
|
|
41
|
+
"lism-css": "0.12.0"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
44
|
+
"@storybook/react-vite": "^10.3.3",
|
|
45
|
+
"eslint": "^9.39.4",
|
|
46
|
+
"storybook": "^10.3.3",
|
|
47
|
+
"stylelint": "^17.4.0",
|
|
45
48
|
"@babel/cli": "^7.28.6",
|
|
46
49
|
"@babel/core": "^7.29.0",
|
|
47
50
|
"@babel/preset-env": "^7.29.0",
|
|
@@ -67,6 +70,10 @@
|
|
|
67
70
|
"format": "prettier --write . --ignore-path ../../.prettierignore",
|
|
68
71
|
"dev": "vite",
|
|
69
72
|
"build": "vite build && pnpm build:css",
|
|
70
|
-
"build:css": "node build-css.js"
|
|
73
|
+
"build:css": "node build-css.js",
|
|
74
|
+
"typecheck": "tsc --noEmit",
|
|
75
|
+
"lint": "pnpm lint:eslint && pnpm lint:style",
|
|
76
|
+
"lint:eslint": "eslint '**/*.{js,mjs,ts,tsx}'",
|
|
77
|
+
"lint:style": "stylelint '**/*.{css,scss}'"
|
|
71
78
|
}
|
|
72
79
|
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { expect, userEvent, within, waitFor } from 'storybook/test';
|
|
3
|
+
import Accordion from './react';
|
|
4
|
+
|
|
5
|
+
const meta: Meta = {
|
|
6
|
+
title: 'UI/Accordion',
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default meta;
|
|
11
|
+
type Story = StoryObj;
|
|
12
|
+
|
|
13
|
+
export const Default: Story = {
|
|
14
|
+
render: () => (
|
|
15
|
+
<Accordion.Root>
|
|
16
|
+
<Accordion.Item>
|
|
17
|
+
<Accordion.Heading>
|
|
18
|
+
<Accordion.Button>アコーディオン 1</Accordion.Button>
|
|
19
|
+
</Accordion.Heading>
|
|
20
|
+
<Accordion.Panel>
|
|
21
|
+
<p>アコーディオン 1 のコンテンツです。</p>
|
|
22
|
+
</Accordion.Panel>
|
|
23
|
+
</Accordion.Item>
|
|
24
|
+
</Accordion.Root>
|
|
25
|
+
),
|
|
26
|
+
play: async ({ canvasElement }) => {
|
|
27
|
+
const canvas = within(canvasElement);
|
|
28
|
+
const button = canvas.getByRole('button');
|
|
29
|
+
|
|
30
|
+
// 初期状態: 閉じている
|
|
31
|
+
await expect(button).toHaveAttribute('aria-expanded', 'false');
|
|
32
|
+
|
|
33
|
+
// クリックで開く
|
|
34
|
+
await userEvent.click(button);
|
|
35
|
+
await waitFor(() => expect(button).toHaveAttribute('aria-expanded', 'true'));
|
|
36
|
+
|
|
37
|
+
// 再クリックで閉じる
|
|
38
|
+
await userEvent.click(button);
|
|
39
|
+
await waitFor(() => expect(button).toHaveAttribute('aria-expanded', 'false'));
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const Multiple: Story = {
|
|
44
|
+
name: '複数アイテム',
|
|
45
|
+
render: () => (
|
|
46
|
+
<Accordion.Root>
|
|
47
|
+
{[1, 2, 3].map((i) => (
|
|
48
|
+
<Accordion.Item key={i}>
|
|
49
|
+
<Accordion.Heading>
|
|
50
|
+
<Accordion.Button>アコーディオン {i}</Accordion.Button>
|
|
51
|
+
</Accordion.Heading>
|
|
52
|
+
<Accordion.Panel>
|
|
53
|
+
<p>アコーディオン {i} のコンテンツです。</p>
|
|
54
|
+
</Accordion.Panel>
|
|
55
|
+
</Accordion.Item>
|
|
56
|
+
))}
|
|
57
|
+
</Accordion.Root>
|
|
58
|
+
),
|
|
59
|
+
play: async ({ canvasElement }) => {
|
|
60
|
+
const canvas = within(canvasElement);
|
|
61
|
+
const buttons = canvas.getAllByRole('button');
|
|
62
|
+
const [btn1, btn2] = buttons;
|
|
63
|
+
|
|
64
|
+
// 1つ目を開く
|
|
65
|
+
await userEvent.click(btn1);
|
|
66
|
+
await waitFor(() => expect(btn1).toHaveAttribute('aria-expanded', 'true'));
|
|
67
|
+
|
|
68
|
+
// 2つ目を開く → 1つ目が閉じる(allowMultiple なし)
|
|
69
|
+
await userEvent.click(btn2);
|
|
70
|
+
await waitFor(() => expect(btn2).toHaveAttribute('aria-expanded', 'true'));
|
|
71
|
+
await waitFor(() => expect(btn1).toHaveAttribute('aria-expanded', 'false'));
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const AllowMultiple: Story = {
|
|
76
|
+
name: 'allowMultiple(複数同時展開可)',
|
|
77
|
+
render: () => (
|
|
78
|
+
<Accordion.Root allowMultiple>
|
|
79
|
+
{[1, 2, 3].map((i) => (
|
|
80
|
+
<Accordion.Item key={i}>
|
|
81
|
+
<Accordion.Heading>
|
|
82
|
+
<Accordion.Button>アコーディオン {i}</Accordion.Button>
|
|
83
|
+
</Accordion.Heading>
|
|
84
|
+
<Accordion.Panel>
|
|
85
|
+
<p>アコーディオン {i} のコンテンツです。複数同時に開けます。</p>
|
|
86
|
+
</Accordion.Panel>
|
|
87
|
+
</Accordion.Item>
|
|
88
|
+
))}
|
|
89
|
+
</Accordion.Root>
|
|
90
|
+
),
|
|
91
|
+
play: async ({ canvasElement }) => {
|
|
92
|
+
const canvas = within(canvasElement);
|
|
93
|
+
const buttons = canvas.getAllByRole('button');
|
|
94
|
+
const [btn1, btn2] = buttons;
|
|
95
|
+
|
|
96
|
+
// 1つ目を開く
|
|
97
|
+
await userEvent.click(btn1);
|
|
98
|
+
await waitFor(() => expect(btn1).toHaveAttribute('aria-expanded', 'true'));
|
|
99
|
+
|
|
100
|
+
// 2つ目を開く → 1つ目はそのまま開いている
|
|
101
|
+
await userEvent.click(btn2);
|
|
102
|
+
await waitFor(() => expect(btn2).toHaveAttribute('aria-expanded', 'true'));
|
|
103
|
+
await expect(btn1).toHaveAttribute('aria-expanded', 'true');
|
|
104
|
+
},
|
|
105
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { Lism } from 'lism-css/astro';
|
|
3
3
|
import Icon from './Icon.astro';
|
|
4
|
-
import {
|
|
4
|
+
import { getButtonProps } from '../getProps';
|
|
5
5
|
|
|
6
6
|
// interface Props extends LismProps {}
|
|
7
7
|
const { isOpen = false, accID = '__LISM_ACC_ID__', ...props } = Astro.props || {};
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
<Lism {...
|
|
10
|
+
<Lism {...getButtonProps(props)} aria-controls={accID} aria-expanded={isOpen ? 'true' : 'false'}>
|
|
11
11
|
<slot />
|
|
12
12
|
<Icon />
|
|
13
13
|
</Lism>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import atts from 'lism-css/lib/helper/atts';
|
|
2
|
+
import mergeSet from 'lism-css/lib/helper/mergeSet';
|
|
3
|
+
|
|
4
|
+
export type AccordionRootProps = {
|
|
5
|
+
lismClass?: string;
|
|
6
|
+
allowMultiple?: boolean;
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type AccordionItemProps = {
|
|
11
|
+
lismClass?: string;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type AccordionHeadingProps = {
|
|
16
|
+
as?: string;
|
|
17
|
+
role?: string;
|
|
18
|
+
lismClass?: string;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type AccordionPanelProps = {
|
|
23
|
+
lismClass?: string;
|
|
24
|
+
_contextID?: string;
|
|
25
|
+
accID?: string;
|
|
26
|
+
isOpen?: boolean;
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export function getRootProps({ lismClass, allowMultiple, ...props }: AccordionRootProps) {
|
|
31
|
+
props.lismClass = atts(lismClass, 'c--accordion');
|
|
32
|
+
if (allowMultiple) props['data-allow-multiple'] = '';
|
|
33
|
+
return props;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function getItemProps({ lismClass, ...props }: AccordionItemProps) {
|
|
37
|
+
props.lismClass = atts(lismClass, 'c--accordion_item');
|
|
38
|
+
return props;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function getHeadingProps({ as = 'div', role, lismClass, set, unset, ...props }: AccordionHeadingProps) {
|
|
42
|
+
const returnProps = {
|
|
43
|
+
lismClass: atts(lismClass, 'c--accordion_heading'),
|
|
44
|
+
as,
|
|
45
|
+
set: mergeSet('plain', set, unset),
|
|
46
|
+
...props,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
if (returnProps.as === 'div') {
|
|
50
|
+
(returnProps as Record<string, unknown>).role = role ?? 'heading';
|
|
51
|
+
}
|
|
52
|
+
return returnProps;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function getButtonProps({ set, unset, ...props }: Record<string, unknown>) {
|
|
56
|
+
return {
|
|
57
|
+
lismClass: 'c--accordion_button',
|
|
58
|
+
as: 'button',
|
|
59
|
+
layout: 'flex',
|
|
60
|
+
set: mergeSet('plain', set, unset),
|
|
61
|
+
g: '10',
|
|
62
|
+
w: '100%',
|
|
63
|
+
ai: 'center',
|
|
64
|
+
jc: 'between',
|
|
65
|
+
...props,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function getPanelProps({ lismClass, _contextID, accID = '__LISM_ACC_ID__', isOpen = false, ...props }: AccordionPanelProps) {
|
|
70
|
+
const panelProps = {
|
|
71
|
+
lismClass: atts(lismClass, 'c--accordion_panel'),
|
|
72
|
+
id: _contextID || accID,
|
|
73
|
+
hidden: isOpen ? undefined : ('until-found' as unknown as boolean),
|
|
74
|
+
pos: 'relative',
|
|
75
|
+
ov: 'hidden',
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const contentProps = { lismClass: 'c--accordion_content', layout: 'flow' as const, ...props };
|
|
79
|
+
|
|
80
|
+
return { panelProps, contentProps };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const defaultProps = {
|
|
84
|
+
icon: {
|
|
85
|
+
lismClass: 'c--accordion_icon a--icon',
|
|
86
|
+
as: 'span',
|
|
87
|
+
pi: 'center',
|
|
88
|
+
fxsh: '0',
|
|
89
|
+
'aria-hidden': 'true',
|
|
90
|
+
},
|
|
91
|
+
} as const;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Lism } from 'lism-css/react';
|
|
1
|
+
import { Lism, type LismComponentProps } from 'lism-css/react';
|
|
2
2
|
import { defaultProps } from '../getProps';
|
|
3
3
|
|
|
4
4
|
// CSS疑似要素(::before / ::after)でアイコンを描画するコンポーネント
|
|
5
|
-
export default function AccIcon(props) {
|
|
5
|
+
export default function AccIcon(props: LismComponentProps) {
|
|
6
6
|
return <Lism {...defaultProps.icon} {...props} />;
|
|
7
7
|
}
|
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { createContext, useRef, useId, useEffect, useContext } from 'react';
|
|
3
|
+
import type { ElementType } from 'react';
|
|
3
4
|
import getLismProps from 'lism-css/lib/getLismProps';
|
|
4
|
-
import { Lism, Stack } from 'lism-css/react';
|
|
5
|
-
import {
|
|
5
|
+
import { Lism, Stack, type LismComponentProps } from 'lism-css/react';
|
|
6
|
+
import {
|
|
7
|
+
getRootProps,
|
|
8
|
+
getItemProps,
|
|
9
|
+
getHeadingProps,
|
|
10
|
+
getPanelProps,
|
|
11
|
+
getButtonProps,
|
|
12
|
+
type AccordionRootProps,
|
|
13
|
+
type AccordionItemProps,
|
|
14
|
+
type AccordionHeadingProps,
|
|
15
|
+
type AccordionPanelProps,
|
|
16
|
+
} from '../getProps';
|
|
6
17
|
import { setEvent } from '../setAccordion';
|
|
7
18
|
import AccIcon from './AccIcon';
|
|
8
19
|
|
|
9
20
|
import '../_style.css';
|
|
10
21
|
|
|
22
|
+
type AccordionContextType = { accID: string } | null;
|
|
23
|
+
|
|
11
24
|
// Context: 純粋なReact環境で AccordionItem → Button / Panel へ accID を共有
|
|
12
25
|
// Astro 環境では Context が使えないため null がフォールバック
|
|
13
|
-
const AccordionContext = createContext(null);
|
|
26
|
+
const AccordionContext = createContext<AccordionContextType>(null);
|
|
14
27
|
|
|
15
28
|
/**
|
|
16
29
|
* 複数の AccordionItem をラップするルート要素
|
|
17
30
|
*/
|
|
18
|
-
export function AccordionRoot({ children, ...props }) {
|
|
31
|
+
export function AccordionRoot({ children, ...props }: AccordionRootProps & LismComponentProps) {
|
|
19
32
|
const rootProps = getRootProps(props);
|
|
20
33
|
return <Stack {...rootProps}>{children}</Stack>;
|
|
21
34
|
}
|
|
@@ -23,8 +36,8 @@ export function AccordionRoot({ children, ...props }) {
|
|
|
23
36
|
/**
|
|
24
37
|
* 個別のアコーディオンアイテム(<div> ベース、setEvent で開閉イベントを登録)
|
|
25
38
|
*/
|
|
26
|
-
export function AccordionItem({ children, ...props }) {
|
|
27
|
-
const ref = useRef(null);
|
|
39
|
+
export function AccordionItem({ children, ...props }: AccordionItemProps & LismComponentProps) {
|
|
40
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
28
41
|
|
|
29
42
|
// コンポーネント単位でユニークIDを生成
|
|
30
43
|
const accID = useId();
|
|
@@ -50,20 +63,29 @@ export function AccordionItem({ children, ...props }) {
|
|
|
50
63
|
* 見出しエリアのラッパー(デフォルトは <div role="heading">)
|
|
51
64
|
* as に h2〜h6 を指定すると role は付与されない
|
|
52
65
|
*/
|
|
53
|
-
export function Heading({ children, ...props }) {
|
|
54
|
-
|
|
66
|
+
export function Heading({ children, ...props }: AccordionHeadingProps & LismComponentProps) {
|
|
67
|
+
const { as: headingAs, ...headingProps } = getHeadingProps(props);
|
|
68
|
+
return (
|
|
69
|
+
<Lism as={headingAs as ElementType} {...headingProps}>
|
|
70
|
+
{children}
|
|
71
|
+
</Lism>
|
|
72
|
+
);
|
|
55
73
|
}
|
|
56
74
|
|
|
75
|
+
type ButtonProps<T extends ElementType = 'button'> = LismComponentProps<T> & {
|
|
76
|
+
accID?: string;
|
|
77
|
+
};
|
|
78
|
+
|
|
57
79
|
/**
|
|
58
80
|
* 開閉トリガーボタン
|
|
59
81
|
* accID: Context から取得できればそれを優先、なければ props / プレースホルダー
|
|
60
82
|
*/
|
|
61
|
-
export function Button({ children, accID: _accID = '__LISM_ACC_ID__', ...props }) {
|
|
83
|
+
export function Button<T extends ElementType = 'button'>({ children, accID: _accID = '__LISM_ACC_ID__', ...props }: ButtonProps<T>) {
|
|
62
84
|
const ctx = useContext(AccordionContext);
|
|
63
85
|
const accID = ctx?.accID || _accID;
|
|
64
86
|
|
|
65
87
|
return (
|
|
66
|
-
<Lism {...
|
|
88
|
+
<Lism {...(getButtonProps(props as Record<string, unknown>) as object)} aria-controls={accID} aria-expanded="false">
|
|
67
89
|
{children}
|
|
68
90
|
<AccIcon />
|
|
69
91
|
</Lism>
|
|
@@ -73,7 +95,7 @@ export function Button({ children, accID: _accID = '__LISM_ACC_ID__', ...props }
|
|
|
73
95
|
/**
|
|
74
96
|
* パネル
|
|
75
97
|
*/
|
|
76
|
-
export function Panel({ children, ...props }) {
|
|
98
|
+
export function Panel({ children, ...props }: AccordionPanelProps & LismComponentProps) {
|
|
77
99
|
const ctx = useContext(AccordionContext);
|
|
78
100
|
const { panelProps, contentProps } = getPanelProps({ _contextID: ctx?.accID, ...props });
|
|
79
101
|
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { waitFrame, waitAnimation, maybePauseAnimation } from '../../helper/animation';
|
|
2
|
+
|
|
3
|
+
// hidden を付け外しする時の値
|
|
4
|
+
let ACCORDION_HIDDEN_VALUE = 'until-found';
|
|
5
|
+
|
|
6
|
+
type AccordionElements = {
|
|
7
|
+
heading: HTMLElement;
|
|
8
|
+
button: HTMLButtonElement;
|
|
9
|
+
panel: HTMLElement;
|
|
10
|
+
content: HTMLElement;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// アコーディオン要素から必要な要素を取得
|
|
14
|
+
const getAccordionElements = (accordionItem: HTMLElement): AccordionElements => {
|
|
15
|
+
const heading = accordionItem.querySelector<HTMLElement>('.c--accordion_heading')!;
|
|
16
|
+
const panel = accordionItem.querySelector<HTMLElement>('.c--accordion_panel')!;
|
|
17
|
+
return {
|
|
18
|
+
heading,
|
|
19
|
+
button: heading.querySelector('button')!,
|
|
20
|
+
panel,
|
|
21
|
+
content: panel.querySelector<HTMLElement>('.c--accordion_content')!,
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// 親に data-allow-multiple がついていなければ、展開中のアコーディオンを閉じる
|
|
26
|
+
const maybeCloseOpenedItems = (accordionItem: HTMLElement): void => {
|
|
27
|
+
const parent = accordionItem.parentNode as HTMLElement | null;
|
|
28
|
+
if (!parent) return;
|
|
29
|
+
|
|
30
|
+
if (parent.hasAttribute('data-allow-multiple')) return;
|
|
31
|
+
|
|
32
|
+
parent.querySelectorAll<HTMLElement>(':scope > [data-opened]').forEach((_a) => void closeAccordion(_a));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
async function openAccordion(accordionItem: HTMLElement): Promise<void> {
|
|
36
|
+
const { panel, content, button } = getAccordionElements(accordionItem);
|
|
37
|
+
|
|
38
|
+
maybePauseAnimation(panel);
|
|
39
|
+
panel.removeAttribute('hidden');
|
|
40
|
+
await waitFrame();
|
|
41
|
+
|
|
42
|
+
accordionItem.style.setProperty('--_panel-h', `${content.offsetHeight}px`);
|
|
43
|
+
await waitFrame();
|
|
44
|
+
|
|
45
|
+
accordionItem.setAttribute('data-opened', '');
|
|
46
|
+
button.setAttribute('aria-expanded', 'true');
|
|
47
|
+
|
|
48
|
+
const status = await waitAnimation(panel);
|
|
49
|
+
|
|
50
|
+
if ('canceled' !== status) {
|
|
51
|
+
accordionItem.style.removeProperty('--_panel-h');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function closeAccordion(accordionItem: HTMLElement): Promise<void> {
|
|
56
|
+
const { panel, button } = getAccordionElements(accordionItem);
|
|
57
|
+
|
|
58
|
+
maybePauseAnimation(panel);
|
|
59
|
+
accordionItem.style.setProperty('--_panel-h', `${panel.offsetHeight}px`);
|
|
60
|
+
await waitFrame();
|
|
61
|
+
|
|
62
|
+
accordionItem.removeAttribute('data-opened');
|
|
63
|
+
button.setAttribute('aria-expanded', 'false');
|
|
64
|
+
accordionItem.style.removeProperty('--_panel-h');
|
|
65
|
+
|
|
66
|
+
const status = await waitAnimation(panel);
|
|
67
|
+
|
|
68
|
+
if ('canceled' !== status) {
|
|
69
|
+
panel.setAttribute('hidden', ACCORDION_HIDDEN_VALUE);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function toggleAccordion(accordionItem: HTMLElement): void {
|
|
74
|
+
if (accordionItem.hasAttribute('data-opened')) {
|
|
75
|
+
void closeAccordion(accordionItem);
|
|
76
|
+
} else {
|
|
77
|
+
maybeCloseOpenedItems(accordionItem);
|
|
78
|
+
void openAccordion(accordionItem);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 個別のアコーディオンにイベントをセット(React用にクリーンアップ関数を返す)
|
|
84
|
+
*/
|
|
85
|
+
export const setEvent = (accordionItem: HTMLElement): (() => void) => {
|
|
86
|
+
const { button, panel } = getAccordionElements(accordionItem);
|
|
87
|
+
|
|
88
|
+
if (panel.hasAttribute('hidden')) {
|
|
89
|
+
ACCORDION_HIDDEN_VALUE = panel.getAttribute('hidden') ?? 'until-found';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const _clickEvent = (e: Event): void => {
|
|
93
|
+
e.preventDefault();
|
|
94
|
+
toggleAccordion(accordionItem);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const _beforematchEvent = (e: Event): void => {
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
toggleAccordion(accordionItem);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
button.addEventListener('click', _clickEvent);
|
|
103
|
+
panel.addEventListener('beforematch', _beforematchEvent);
|
|
104
|
+
|
|
105
|
+
return () => {
|
|
106
|
+
button.removeEventListener('click', _clickEvent);
|
|
107
|
+
panel.removeEventListener('beforematch', _beforematchEvent);
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* ページ内の全アコーディオンにイベントをセット(Astro用)
|
|
113
|
+
*/
|
|
114
|
+
const setAccordion = (): void => {
|
|
115
|
+
const accordionAll = document.querySelectorAll<HTMLElement>('.c--accordion_item');
|
|
116
|
+
accordionAll.forEach((accordionItem) => {
|
|
117
|
+
setEvent(accordionItem);
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
export default setAccordion;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import Alert from './react/Alert';
|
|
3
|
+
import PRESETS from './presets';
|
|
4
|
+
|
|
5
|
+
const presetTypes = Object.keys(PRESETS);
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof Alert> = {
|
|
8
|
+
title: 'UI/Alert',
|
|
9
|
+
component: Alert,
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
argTypes: {
|
|
12
|
+
children: { control: false },
|
|
13
|
+
type: { control: 'select', options: presetTypes },
|
|
14
|
+
layout: { control: 'select', options: ['flex', 'sideMain'] },
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default meta;
|
|
19
|
+
type Story = StoryObj<typeof Alert>;
|
|
20
|
+
|
|
21
|
+
export const Default: Story = {
|
|
22
|
+
args: {
|
|
23
|
+
type: 'alert',
|
|
24
|
+
children: 'アラートのメッセージです。',
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const Point: Story = {
|
|
29
|
+
args: { type: 'point', children: 'ポイントのメッセージです。' },
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const Warning: Story = {
|
|
33
|
+
args: { type: 'warning', children: '警告のメッセージです。' },
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const Check: Story = {
|
|
37
|
+
args: { type: 'check', children: 'チェックのメッセージです。' },
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const Help: Story = {
|
|
41
|
+
args: { type: 'help', children: 'ヘルプのメッセージです。' },
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const Info: Story = {
|
|
45
|
+
args: { type: 'info', children: '情報のメッセージです。' },
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const SideMain: Story = {
|
|
49
|
+
name: 'layout: sideMain',
|
|
50
|
+
args: {
|
|
51
|
+
type: 'alert',
|
|
52
|
+
layout: 'sideMain',
|
|
53
|
+
children: 'サイドメインレイアウトのアラートです。',
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const CustomIcon: Story = {
|
|
58
|
+
name: 'カスタムアイコン',
|
|
59
|
+
args: {
|
|
60
|
+
icon: 'star',
|
|
61
|
+
keycolor: 'purple',
|
|
62
|
+
children: 'カスタムアイコンとカラー指定。',
|
|
63
|
+
},
|
|
64
|
+
};
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import PRESETS from './presets';
|
|
2
|
+
import type { LayoutType } from 'lism-css/lib/getLismProps';
|
|
3
|
+
import type { IconProps } from 'lism-css/react';
|
|
2
4
|
|
|
3
5
|
export type AlertProps = {
|
|
4
6
|
type?: string;
|
|
5
7
|
keycolor?: string;
|
|
6
|
-
layout?:
|
|
7
|
-
icon?:
|
|
8
|
+
layout?: LayoutType;
|
|
9
|
+
icon?: IconProps['icon'];
|
|
8
10
|
flow?: string;
|
|
9
11
|
[key: string]: unknown;
|
|
10
12
|
};
|
|
11
13
|
|
|
12
14
|
export default function getAlertProps({ type = 'alert', keycolor, layout = 'flex', icon, flow = 's', ...props }: AlertProps) {
|
|
13
15
|
const presetData = type ? PRESETS[type] : null;
|
|
14
|
-
const _icon = icon || presetData?.icon || 'info';
|
|
16
|
+
const _icon = (icon || presetData?.icon || 'info') as IconProps['icon'];
|
|
15
17
|
const _color = keycolor || presetData?.color || 'currentColor';
|
|
16
18
|
|
|
17
19
|
return {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { Flow, Lism, Center, Icon } from 'lism-css/react';
|
|
1
|
+
import type { ElementType } from 'react';
|
|
2
|
+
import { Flow, Lism, Center, Icon, type LismComponentProps } from 'lism-css/react';
|
|
3
3
|
import getAlertProps, { type AlertProps } from '../getProps';
|
|
4
4
|
|
|
5
|
-
export default function Alert({ children, ...inputProps }: AlertProps &
|
|
5
|
+
export default function Alert<T extends ElementType = 'div'>({ children, ...inputProps }: AlertProps & LismComponentProps<T>) {
|
|
6
6
|
const { icon, layout, flow, ...alertProps } = getAlertProps(inputProps);
|
|
7
7
|
|
|
8
8
|
return (
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import Avatar from './react/Avatar';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof Avatar> = {
|
|
5
|
+
title: 'UI/Avatar',
|
|
6
|
+
component: Avatar,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
argTypes: {
|
|
9
|
+
src: { control: 'text' },
|
|
10
|
+
alt: { control: 'text' },
|
|
11
|
+
size: { control: 'text' },
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
type Story = StoryObj<typeof Avatar>;
|
|
17
|
+
|
|
18
|
+
export const Default: Story = {
|
|
19
|
+
args: {
|
|
20
|
+
src: 'https://cdn.lism-css.com/dummy-image.jpg',
|
|
21
|
+
alt: 'ユーザーアバター',
|
|
22
|
+
size: '4rem',
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const Small: Story = {
|
|
27
|
+
name: '小サイズ',
|
|
28
|
+
args: {
|
|
29
|
+
src: 'https://cdn.lism-css.com/dummy-image.jpg',
|
|
30
|
+
alt: '',
|
|
31
|
+
size: '2rem',
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const Large: Story = {
|
|
36
|
+
name: '大サイズ',
|
|
37
|
+
args: {
|
|
38
|
+
src: 'https://cdn.lism-css.com/dummy-image.jpg',
|
|
39
|
+
alt: '',
|
|
40
|
+
size: '8rem',
|
|
41
|
+
},
|
|
42
|
+
};
|