Skip to content

Commit

Permalink
fix(ListItemExpandIcon): remove disableTransition and rename behavior…
Browse files Browse the repository at this point in the history
… prop
  • Loading branch information
IsaevAlexandr committed Sep 6, 2024
1 parent af9266c commit 62c29ac
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const WithGroupSelectionAndCustomIconStory = ({
<Button.Icon>
<ListItemExpandIcon
expanded={itemProps.content.expanded}
kind="action"
behavior="action"
/>
</Button.Icon>
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const WithItemLinksAndActionsStory = (props: WithItemLinksAndActionsStory
<Button.Icon>
<ListItemExpandIcon
expanded={itemProps.content.expanded}
kind="action"
behavior="action"
/>
</Button.Icon>
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const WithGroupSelectionControlledStateAndCustomIconExample = ({
<Button.Icon>
<ListItemExpandIcon
expanded={props.content.expanded}
kind="action"
behavior="action"
/>
</Button.Icon>
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const WithItemLinksAndActionsExample = (storyProps: WithItemLinksAndActio
<Button.Icon>
<ListItemExpandIcon
expanded={props.content.expanded}
kind="state"
behavior="state"
/>
</Button.Icon>
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,4 @@ $block: '.#{variables.$ns}list-item-expand-icon';

#{$block} {
flex-shrink: 0;

&_disableTransition {
transition: none;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,33 @@ export interface ListItemExpandIconProps extends ListItemExpandIconRenderProps {

export const ListItemExpandIcon = ({
expanded,
disableTransition,
kind = 'action',
behavior = 'action',
disabled,
}: ListItemExpandIconProps) => {
return (
<ArrowToggle
direction={getIconDirection({kind, expanded})}
className={b({disableTransition}, colorText({color: disabled ? 'hint' : undefined}))}
direction={getIconDirection({behavior, expanded})}
className={b(null, colorText({color: disabled ? 'hint' : undefined}))}
size={16}
/>
);
};

function getIconDirection({
kind,
behavior,
expanded,
}: Pick<ListItemExpandIconRenderProps, 'expanded' | 'kind'>): ArrowToggleProps['direction'] {
if (expanded && kind === 'action') {
}: Pick<ListItemExpandIconRenderProps, 'expanded' | 'behavior'>): ArrowToggleProps['direction'] {
if (expanded && behavior === 'action') {
return 'top';
} else if (expanded && kind === 'state') {
} else if (expanded && behavior === 'state') {
return 'bottom';
} else if (expanded && kind === 'state-inverse') {
} else if (expanded && behavior === 'state-inverse') {
return 'bottom';
} else if (kind === 'action') {
} else if (behavior === 'action') {
return 'bottom';
} else if (kind === 'state') {
} else if (behavior === 'state') {
return 'right';
} else if (kind === 'state-inverse') {
} else if (behavior === 'state-inverse') {
return 'left';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ const InsideButtonExample = (props: ListItemExpandIconProps) => {

#### Props

| Name | Description | Type | Default |
| :---------------- | :---------------------------------------------- | :-------------------------------: | :-----: |
| expanded | icon state | `boolean` | |
| disableTransition | disable animation while `expanded` state change | `boolean` | |
| disabled | disabled view type | `boolean` | |
| kind | The type of behavior of the component | `state`, `state-inverse`,`action` | |
| Name | Description | Type | Default |
| :------- | :---------------------------- | :-------------------------------: | :-----: |
| expanded | icon state | `boolean` | |
| disabled | disabled view type | `boolean` | |
| behavior | The behavior of the component | `state`, `state-inverse`,`action` | |
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const ListItemViewContent = ({
}: ListItemViewContentProps) => {
const expandIconNode = isGroup ? (
<RenderExpandIcon
kind={expandIconPlacement === 'start' ? 'state' : 'action'}
behavior={expandIconPlacement === 'start' ? 'state' : 'action'}
expanded={expanded}
disabled={disabled}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ const stories: ListItemViewProps[] = [
</Text>
),
expanded: true,
renderExpandIcon: (props) => <ListItemExpandIcon {...props} disableTransition />,
isGroup: true,
startSlot: <StartSlot />,
indentation: 1,
Expand Down
6 changes: 2 additions & 4 deletions src/components/useList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,12 @@ export type ItemState = {

export interface ListItemExpandIconRenderProps {
/**
* The type of behavior of the component
* The behavior of the component:
*
* - action - to indicate user actions. For example, for an icon inside a button;
* - state - to indicate the current state of the element;
*/
kind: 'state' | 'state-inverse' | 'action';

disableTransition?: boolean;
behavior: 'state' | 'state-inverse' | 'action';
expanded?: boolean;
disabled?: boolean;
}
Expand Down

0 comments on commit 62c29ac

Please sign in to comment.