-
Notifications
You must be signed in to change notification settings - Fork 6
disclosureを追加 #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
disclosureを追加 #91
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9cf9974
Add disclosure component
itoh4126 a53729c
Fix lint: correct property order in disclosure mixin
itoh4126 5376d0a
Update package-lock.json to include disclosure package
itoh4126 6e78729
rename class
itoh4126 f47e24b
disclosureのsummaryのleading iconとtextのgapをxsに変更
itoh4126 ec7628d
update package-lock.json
itoh4126 ffd759f
disclosureのsample codeのマークアップにおけるcontentクラスをbodyクラスに変更
itoh4126 d9334a1
Merge remote-tracking branch 'origin/main' into add-disclosure-component
itoh4126 97b41b3
Merge main into add-disclosure-component, update dependencies to v4
itoh4126 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| @forward "./mixins" show style, export; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| @use "sass:map"; | ||
| @use "@pepabo-inhouse/adapter/functions" as adapter; | ||
| @use "@pepabo-inhouse/cell/mixins" as cell; | ||
| @use "./variables"; | ||
|
|
||
| @mixin style($option: variables.$default-option) { | ||
| $option: map.merge(variables.$default-option, $option); | ||
|
|
||
| > ._leading { | ||
| @include -summary-proto( | ||
| $density: map.get($option, density), | ||
| $size: map.get($option, size) | ||
| ); | ||
| } | ||
|
|
||
| &[open] > ._leading { | ||
| background-color: | ||
| adapter.get-background-overlay-color( | ||
| $brightness: light, | ||
| $state: activated | ||
| ); | ||
|
|
||
| > ._icon { | ||
| transform: rotate(90deg); | ||
| } | ||
| } | ||
|
|
||
| @each $size in adapter.get-cell-sizes() { | ||
| &.-size-#{$size} > ._leading { | ||
| @include -summary-proto( | ||
| $density: map.get($option, density), | ||
| $size: $size | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| @each $density in adapter.get-densities() { | ||
| &.-density-#{$density} > ._leading { | ||
| @include -summary-proto( | ||
| $density: $density, | ||
| $size: map.get($option, size) | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| @each $density in adapter.get-densities() { | ||
| @each $size in adapter.get-cell-sizes() { | ||
| &.-density-#{$density}.-size-#{$size} > ._leading { | ||
| @include -summary-proto($density: $density, $size: $size); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @mixin export { | ||
| .in-disclosure { | ||
| @include style; | ||
| } | ||
| } | ||
|
|
||
| @mixin -summary-proto($density: normal, $size: m) { | ||
| @include cell.style((density: $density, size: $size)); | ||
|
|
||
| display: flex; | ||
| gap: adapter.get-gap-size(xs); | ||
| align-items: center; | ||
| list-style: none; | ||
| background-color: | ||
| adapter.get-background-overlay-color( | ||
| $brightness: light, | ||
| $state: enabled | ||
| ); | ||
| cursor: pointer; | ||
|
|
||
| &::-webkit-details-marker { | ||
| display: none; | ||
| } | ||
|
|
||
| &:hover, | ||
| &.--hover { | ||
| background-color: | ||
| adapter.get-background-overlay-color( | ||
| $brightness: light, | ||
| $state: hover | ||
| ); | ||
| } | ||
|
|
||
| &:focus-visible, | ||
| &.--focused { | ||
| background-color: | ||
| adapter.get-background-overlay-color( | ||
| $brightness: light, | ||
| $state: focused | ||
| ); | ||
| outline: adapter.get-focus-ring-outline(); | ||
| outline-offset: adapter.get-focus-ring-outline-offset(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| $default-option: ( | ||
| density: normal, | ||
| size: m, | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| @use "./mixins"; | ||
| @include mixins.export; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "name": "@pepabo-inhouse/disclosure", | ||
| "description": "Inhouse Components for the web disclosure component", | ||
| "version": "4.0.0", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/pepabo/inhouse-components-web.git", | ||
| "directory": "packages/disclosure" | ||
| }, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pepabo-inhouse/adapter": "^4.0.0", | ||
| "@pepabo-inhouse/cell": "^4.0.0", | ||
| "@pepabo-inhouse/icon": "^4.0.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@pepabo-inhouse/constants": "^4.0.0", | ||
| "@pepabo-inhouse/flavor": "^4.0.0", | ||
| "@pepabo-inhouse/tokens": "^2.4.0" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
packages/stories-web/src/components/disclosure/Disclosure.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import React, { FC, ReactNode } from 'react' | ||
| import { Density, Size } from '../types' | ||
| import Icon from '../Icon' | ||
|
|
||
| export interface Props { | ||
| children: ReactNode | ||
| density?: Density | ||
| open?: boolean | ||
| size?: Extract<Size, 's' | 'm' | 'l'> | ||
| summary: string | ||
| } | ||
|
|
||
| const Disclosure: FC<Props> = (props: Props) => { | ||
| const { | ||
| children, | ||
| density, | ||
| open, | ||
| size, | ||
| summary, | ||
| ...rest | ||
| } = props | ||
|
|
||
| const classes = ['in-disclosure'] | ||
|
|
||
| if (typeof density !== 'undefined') { | ||
| classes.push(`-density-${density}`) | ||
| } | ||
|
|
||
| if (typeof size !== 'undefined') { | ||
| classes.push(`-size-${size}`) | ||
| } | ||
|
|
||
| return ( | ||
| <details | ||
| className={classes.join(' ')} | ||
| open={open} | ||
| {...rest} | ||
| > | ||
| <summary className='_leading'> | ||
| <Icon | ||
| className='_icon' | ||
| icon='chevron_right' | ||
| /> | ||
| {summary} | ||
| </summary> | ||
| <div className='_body'> | ||
| {children} | ||
| </div> | ||
| </details> | ||
| ) | ||
| } | ||
|
|
||
| export default Disclosure | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| import type { StoryFn, Meta } from '@storybook/react' | ||
| import React from 'react' | ||
| import Disclosure, { Props } from './components/disclosure/Disclosure' | ||
|
|
||
| export default { | ||
| title: 'Components/Disclosure', | ||
| component: Disclosure, | ||
| argTypes: { | ||
| density: { | ||
| control: { type: 'select' }, | ||
| options: ['dense', 'normal', 'comfort'], | ||
| }, | ||
| size: { | ||
| control: { type: 'select' }, | ||
| options: ['s', 'm', 'l'], | ||
| }, | ||
| }, | ||
| } as Meta | ||
|
|
||
| const Template: StoryFn<Props> = (args) => <Disclosure {...args} /> | ||
|
|
||
| const content = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.' | ||
|
|
||
| export const Default = Template.bind({}) | ||
| Default.args = { | ||
| summary: 'Summary text', | ||
| children: content, | ||
| density: 'normal', | ||
| size: 'm', | ||
| } | ||
|
|
||
| export const Open = Template.bind({}) | ||
| Open.args = { | ||
| summary: 'Summary text', | ||
| children: content, | ||
| density: 'normal', | ||
| size: 'm', | ||
| open: true, | ||
| } | ||
|
|
||
| export const SizeSmall = Template.bind({}) | ||
| SizeSmall.args = { | ||
| summary: 'Summary text (size: s)', | ||
| children: content, | ||
| density: 'normal', | ||
| size: 's', | ||
| open: true, | ||
| } | ||
|
|
||
| export const SizeLarge = Template.bind({}) | ||
| SizeLarge.args = { | ||
| summary: 'Summary text (size: l)', | ||
| children: content, | ||
| density: 'normal', | ||
| size: 'l', | ||
| open: true, | ||
| } | ||
|
|
||
| export const DensityDense = Template.bind({}) | ||
| DensityDense.args = { | ||
| summary: 'Summary text (density: dense)', | ||
| children: content, | ||
| density: 'dense', | ||
| size: 'm', | ||
| open: true, | ||
| } | ||
|
|
||
| export const DensityComfort = Template.bind({}) | ||
| DensityComfort.args = { | ||
| summary: 'Summary text (density: comfort)', | ||
| children: content, | ||
| density: 'comfort', | ||
| size: 'm', | ||
| open: true, | ||
| } | ||
|
|
||
| const MultipleTemplate: StoryFn = () => ( | ||
| <> | ||
| <Disclosure | ||
| density='normal' | ||
| size='m' | ||
| summary='First item' | ||
| > | ||
| {content} | ||
| </Disclosure> | ||
| <Disclosure | ||
| density='normal' | ||
| open | ||
| size='m' | ||
| summary='Second item (open)' | ||
| > | ||
| {content} | ||
| </Disclosure> | ||
| <Disclosure | ||
| density='normal' | ||
| size='m' | ||
| summary='Third item' | ||
| > | ||
| {content} | ||
| </Disclosure> | ||
| </> | ||
| ) | ||
|
|
||
| export const Multiple = MultipleTemplate.bind({}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.