Action menu refactoring (#11454)
# Description Closes [#696](https://github.com/twentyhq/core-team-issues/issues/696) - `useAction` hooks have been removed for all actions - Every action can now declare a react component - Some standard action components have been introduced: `Action`, `ActionLink` and `ActionModal` - The `ActionDisplay` component uses the new `displayType` prop of the `ActionMenuContext` to render the right component for the action according to its container: `ActionButton`, `ActionDropdownItem` or `ActionListItem` - The `ActionDisplayer` wraps the action component inside a context which gives it all the information about the action -`actionMenuEntriesComponenState` has been removed and now all actions are computed directly using `useRegisteredAction` - This computation is done inside `ActionMenuContextProvider` and the actions are passed inside a context - `actionMenuType` gives information about the container of the action, so the action can know wether or not to close this container upon execution
This commit is contained in:
@ -345,6 +345,7 @@ const StyledButton = styled('button', {
|
||||
padding: ${({ theme }) => {
|
||||
return `0 ${theme.spacing(2)} 0 ${theme.spacing(2)}`;
|
||||
}};
|
||||
box-sizing: border-box;
|
||||
|
||||
transition: background 0.1s ease;
|
||||
|
||||
|
||||
@ -20,10 +20,14 @@ export type IconButtonProps = {
|
||||
dataTestId?: string;
|
||||
ariaLabel?: string;
|
||||
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
||||
to?: string;
|
||||
};
|
||||
|
||||
const StyledButton = styled.button<
|
||||
Pick<IconButtonProps, 'variant' | 'size' | 'position' | 'accent' | 'focus'>
|
||||
Pick<
|
||||
IconButtonProps,
|
||||
'variant' | 'size' | 'position' | 'accent' | 'focus' | 'to'
|
||||
>
|
||||
>`
|
||||
align-items: center;
|
||||
${({ theme, variant, accent, disabled, focus }) => {
|
||||
@ -252,6 +256,7 @@ export const IconButton = ({
|
||||
dataTestId,
|
||||
ariaLabel,
|
||||
onClick,
|
||||
to,
|
||||
}: IconButtonProps) => {
|
||||
const theme = useTheme();
|
||||
return (
|
||||
@ -266,6 +271,7 @@ export const IconButton = ({
|
||||
className={className}
|
||||
onClick={onClick}
|
||||
aria-label={ariaLabel}
|
||||
to={to}
|
||||
>
|
||||
{Icon && <Icon size={theme.icon.size.md} />}
|
||||
</StyledButton>
|
||||
|
||||
Reference in New Issue
Block a user