Skip to content
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

feat: fix icon button styling #1076

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions design-system/IconButton/IconButton.example.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { memo } from "react";

import { useAppTheme } from "../../theme/useAppTheme";
import { HStack } from "../HStack";
import { VStack } from "../VStack";
import { IconButton } from "./IconButton";

export const IconButtonExample = memo(function IconButtonExample() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Storyboard worthwhile? Or some sort of example screen?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every time I added Storyboard in my app it was always overkill. Even when we were 10. So for now I'm just doing those so that if ever we need to see we can just import those.

Might find a better solution later or even delete them TBH.

const { theme } = useAppTheme();

return (
<VStack
style={{
rowGap: theme.spacing.md,
paddingTop: theme.spacing["4xl"],
}}
>
<VStack style={{ rowGap: theme.spacing.md }}>
{/* Fill Variant */}
<HStack style={{ columnGap: theme.spacing.sm }}>
<IconButton variant="fill" iconName="star" />
<IconButton variant="fill" iconName="star" disabled />
<IconButton
variant="fill"
iconName="star"
action="primary"
size="lg"
/>
</HStack>

{/* Outline Variant */}
<HStack style={{ columnGap: theme.spacing.sm }}>
<IconButton variant="outline" iconName="star" />
<IconButton variant="outline" iconName="star" disabled />
<IconButton variant="outline" iconName="star" size="lg" />
</HStack>

{/* Ghost Variant */}
<HStack style={{ columnGap: theme.spacing.sm }}>
<IconButton variant="ghost" iconName="star" />
<IconButton variant="ghost" iconName="star" disabled />
<IconButton variant="ghost" iconName="star" size="lg" />
</HStack>
</VStack>
</VStack>
);
});
13 changes: 7 additions & 6 deletions design-system/IconButton/IconButton.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ export const getIconButtonViewStyle =
// Set size
const sizeStyles = {
md: {
width: spacing.xl,
height: spacing.xl,
},
lg: {
width: spacing.xxl,
height: spacing.xxl,
},
lg: {
width: spacing["3xl"],
height: spacing["3xl"],
},
};
Object.assign(style, sizeStyles[size]);

Expand All @@ -65,9 +65,10 @@ export const getIconButtonViewStyle =
style.backgroundColor = "transparent";
if (pressed) {
style.backgroundColor = colors.fill.minimal;
style.borderColor = colors.fill.minimal;
}
if (disabled) {
style.borderColor = colors.border.secondary;
style.borderColor = colors.border.subtle;
style.backgroundColor = "transparent";
}
break;
Expand Down Expand Up @@ -171,7 +172,7 @@ export const getIconProps =

props.size = sizeMap[size];

if (disabled) {
if (disabled && variant !== "fill") {
props.color = colors.text.tertiary;
return props;
}
Expand Down
Loading