-
Notifications
You must be signed in to change notification settings - Fork 4
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
APP-34027: feature(ExpansionCard): introduce new component #2469
Merged
Merged
Changes from 1 commit
Commits
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
This file contains 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,19 @@ | ||
import { Modal } from '@delangle/use-modal' | ||
|
||
import { CardProps } from '../Card' | ||
|
||
export interface ExpansionCardProps | ||
extends Omit<CardProps, 'title' | 'children'> { | ||
children?: React.ReactNode | ||
defaultOpen?: boolean | ||
description?: string | React.ReactNode | ||
disabled?: boolean | ||
error?: boolean | ||
header?: React.ReactNode | ((state: Modal) => React.ReactNode) | ||
onToggle?: (e?: React.MouseEvent) => void | ||
/** | ||
* Positionb sticky when opened | ||
Carolinevp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/ | ||
sticky?: boolean | ||
title?: string | React.ReactNode | ||
} |
This file contains 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,86 @@ | ||
import * as React from 'react' | ||
import styled from 'styled-components' | ||
|
||
import { CenteredComponent } from '../_storybook/CenteredComponent' | ||
import { withGrid } from '../_storybook/withGrid' | ||
import { Text } from '../Text' | ||
|
||
import { ExpansionCard, ExpansionCardProps } from './index' | ||
|
||
const CardChildrenContainer = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
width: 300px; | ||
max-width: calc(100vw - 48px); | ||
|
||
& > img { | ||
width: 100%; | ||
height: auto; | ||
} | ||
` | ||
|
||
const CardChildren = () => ( | ||
<CardChildrenContainer> | ||
<Text type="small"> | ||
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae delectus | ||
distinctio eligendi eum exercitationem facilis. | ||
</Text> | ||
</CardChildrenContainer> | ||
) | ||
|
||
const GRID_PROPS = { | ||
children: <CardChildren />, | ||
} | ||
|
||
const GRID_LINES = [ | ||
{ | ||
label: 'Default', | ||
}, | ||
{ | ||
label: 'With title', | ||
props: { | ||
title: <Text type="caption">Title</Text>, | ||
}, | ||
outline: true, | ||
}, | ||
{ | ||
label: 'With title and description', | ||
props: { | ||
title: <Text type="caption">Title</Text>, | ||
description: <Text type="caption">Description</Text>, | ||
}, | ||
outline: true, | ||
}, | ||
] | ||
|
||
const GRID_ITEMS = [ | ||
{ | ||
label: 'Default', | ||
}, | ||
] | ||
|
||
const Grid = withGrid<ExpansionCardProps>({ | ||
props: GRID_PROPS, | ||
lines: GRID_LINES, | ||
items: GRID_ITEMS, | ||
})(ExpansionCard) | ||
|
||
export default { | ||
title: 'Layouts/ExpansionCard', | ||
component: ExpansionCard, | ||
} | ||
|
||
export const basic = (props: ExpansionCardProps) => ( | ||
<CenteredComponent> | ||
<ExpansionCard {...props}>{GRID_PROPS.children}</ExpansionCard> | ||
</CenteredComponent> | ||
) | ||
|
||
basic.parameters = { | ||
design: { | ||
type: 'figma', | ||
url: 'https://www.figma.com/file/LfGEUbovutcTpygwzrfTYbl5/Desktop-components?node-id=4%3A0', | ||
}, | ||
} | ||
|
||
export const gallery = () => <Grid /> |
This file contains 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,7 @@ | ||
import styled from 'styled-components' | ||
|
||
import { ExpansionPanelItem as BaseExpansionPanelItem } from '../ExpansionPanelItem' | ||
|
||
export const ExpansionPanelItem = styled(BaseExpansionPanelItem)` | ||
--expansion-panel-item-horizontal-padding: 12px; | ||
` |
This file contains 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,31 @@ | ||
import * as React from 'react' | ||
|
||
import { Card } from '../Card' | ||
import { ExpansionPanel } from '../ExpansionPanel' | ||
|
||
import { ExpansionCardProps } from './ExpansionCard.interface' | ||
import { ExpansionPanelItem } from './ExpansionCard.style' | ||
|
||
export const ExpansionCard = React.forwardRef< | ||
HTMLDivElement | HTMLButtonElement, | ||
ExpansionCardProps | ||
>((props, ref) => { | ||
const { | ||
description, | ||
children, | ||
outline = true, | ||
spacing = 'narrow-horizontal-only', | ||
title, | ||
...rest | ||
} = props | ||
|
||
return ( | ||
<Card outline={outline} spacing={spacing} ref={ref}> | ||
<ExpansionPanel {...rest}> | ||
<ExpansionPanelItem title={title} description={description} inCard> | ||
{children} | ||
</ExpansionPanelItem> | ||
</ExpansionPanel> | ||
</Card> | ||
) | ||
}) |
This file contains 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,3 @@ | ||
export { ExpansionCard } from './ExpansionCard' | ||
|
||
export { ExpansionCardProps } from './ExpansionCard.interface' |
This file contains 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 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 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 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 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should avoid usage of boolean for these styles in the future.
I think something like
style: 'error' | 'warning'
would be much betterThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jean9696 Here I am just passing the props of
ExpansionPanelItem
. I am not sure that I want to make the change for this component here