Skip to content

Commit

Permalink
feat: TextField design system (#1074)
Browse files Browse the repository at this point in the history
* add TextField and fix IconButton

* delete old button
  • Loading branch information
thierryskoda authored and alexrisch committed Oct 28, 2024
1 parent dd9036f commit ca81dda
Show file tree
Hide file tree
Showing 14 changed files with 550 additions and 301 deletions.
139 changes: 0 additions & 139 deletions design-system/Button/OldButton.tsx

This file was deleted.

153 changes: 0 additions & 153 deletions design-system/IconButton.tsx

This file was deleted.

50 changes: 50 additions & 0 deletions design-system/IconButton/IconButton.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,53 @@ export const getIconStyle =

return style;
};

export const getIconProps =
({
variant,
size,
action,
pressed = false,
disabled = false,
}: IconButtonStyleProps) =>
(theme: Theme) =>
// TODO: fix once we fixed IconProps
// : Partial<IIconProps>
{
const { colors, spacing } = theme;

const props: any =
// :Partial<IIconProps>
{};

// Set icon size
const sizeMap = {
md: spacing.md,
lg: spacing.lg,
};

props.size = sizeMap[size];

if (disabled) {
props.color = colors.text.tertiary;
return props;
}

if (action === "primary") {
switch (variant) {
case "fill":
props.color = colors.text.inverted.primary;
break;

case "outline":
case "ghost":
props.color = colors.text.primary;
break;

default:
break;
}
}

return props;
};
29 changes: 27 additions & 2 deletions design-system/IconButton/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import { useAppTheme } from "../../theme/useAppTheme";
import { Icon } from "../Icon/Icon";
import { Pressable } from "../Pressable";
import { IIconButtonProps } from "./IconButton.props";
import { getIconButtonViewStyle, getIconStyle } from "./IconButton.styles";
import {
getIconButtonViewStyle,
getIconProps,
getIconStyle,
} from "./IconButton.styles";

export function IconButton(props: IIconButtonProps) {
const {
Expand Down Expand Up @@ -65,6 +69,21 @@ export function IconButton(props: IIconButtonProps) {
[themed, variant, size, action, disabled]
);

// For now until we fix Icon
const iconProps = useCallback(
({ pressed }: PressableStateCallbackType) =>
themed(
getIconProps({
variant,
size,
action,
pressed,
disabled,
})
),
[themed, variant, size, action, disabled]
);

return (
<Pressable
style={viewStyle}
Expand All @@ -75,7 +94,13 @@ export function IconButton(props: IIconButtonProps) {
>
{({ pressed }) => {
if (iconName) {
return <Icon picto={iconName} style={iconStyle({ pressed })} />;
return (
<Icon
picto={iconName}
style={iconStyle({ pressed })}
{...iconProps({ pressed })}
/>
);
}

return icon;
Expand Down
Loading

0 comments on commit ca81dda

Please sign in to comment.