Skip to content

Commit

Permalink
Fix select value (#183)
Browse files Browse the repository at this point in the history
* Fix select ellipsis issue

* Fix Badge alignment

* Fix Badge styling
  • Loading branch information
vineethasok authored Oct 20, 2023
1 parent f8d1f74 commit faf5724
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 25 deletions.
40 changes: 18 additions & 22 deletions src/components/Badge/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import styled from "styled-components";
import { HorizontalDirection, Icon, IconName } from "@/components";
import { HTMLAttributes, MouseEvent, ReactNode } from "react";
import { EllipsisContainer } from "../commonElement";
import IconWrapper from "../IconWrapper/IconWrapper";
export type BadgeState =
| "default"
| "success"
Expand Down Expand Up @@ -47,6 +48,8 @@ const Content = styled.div<{ $state?: BadgeState; $size?: BadgeSize }>`
display: inline-flex;
align-items: center;
gap: ${({ $size = "md", theme }) => theme.click.badge.space[$size].gap};
max-width: 100%;
justify-content: flex-start;
`;

const SvgContainer = styled.svg<{ $state?: BadgeState; $size?: BadgeSize }>`
Expand All @@ -58,13 +61,15 @@ const SvgContainer = styled.svg<{ $state?: BadgeState; $size?: BadgeSize }>`
`;
const BadgeContent = styled(EllipsisContainer)<{
$state?: BadgeState;
$size?: BadgeSize;
size?: BadgeSize;
}>`
width: auto;
overflow: hidden;
svg {
${({ $state = "default", $size = "md", theme }) => `
${({ $state = "default", size = "md", theme }) => `
color: ${theme.click.badge.color.text[$state]};
height: ${theme.click.badge.icon[$size].size.height};
width: ${theme.click.badge.icon[$size].size.width};
height: ${theme.click.badge.icon[size].size.height};
width: ${theme.click.badge.icon[size].size.width};
gap: inherit;
`}
}
Expand All @@ -88,24 +93,15 @@ export const Badge = ({
{...props}
>
<Content>
{icon && iconDir === "start" && (
<SvgContainer
as={Icon}
name={icon}
$state={state}
$size={size}
/>
)}
<BadgeContent>{text}</BadgeContent>
{icon && iconDir === "end" && (
<SvgContainer
as={Icon}
name={icon}
$state={state}
$size={size}
/>
)}

<BadgeContent
as={IconWrapper}
icon={icon}
iconDir={iconDir}
size={size}
$state={state}
>
{text}
</BadgeContent>
{dismissible && (
<SvgContainer
name="cross"
Expand Down
11 changes: 10 additions & 1 deletion src/components/Select/MultiSelectValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ const BadgeList = styled.div`
color: inherit;
`;

const MultiSelectBadge = styled.div`
width: 100%;
width: -webkit-fill-available;
width: fill-available;
width: stretch;
max-width: fit-content;
`;

interface MultiSelectValueProps {
selectedValues: Array<string>;
valueNode: Map<string, SelectItemProps>;
Expand Down Expand Up @@ -91,7 +99,8 @@ export const MultiSelectValue = ({
} as DismissibleBadge;
}
return (
<Badge
<MultiSelectBadge
as={Badge}
key={`multi-select-${id}-${value}`}
size="sm"
state={disabled ? "disabled" : "default"}
Expand Down
3 changes: 1 addition & 2 deletions src/components/Select/common/SelectStyled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ export const SelectPopoverRoot = styled(Root)`
`;

export const SelectValue = styled.div`
display: flex;
flex-direction: column;
text-align: left;
flex: 1;
gap: inherit;
color: inherit;
font: inherit;
overflow: hidden;
`;

export const StyledSelectTrigger = styled(Trigger)<{ $error: boolean }>`
Expand Down

1 comment on commit faf5724

@vercel
Copy link

@vercel vercel bot commented on faf5724 Oct 20, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

click-ui – ./

click-ui-git-main-clickhouse.vercel.app
click-ui.vercel.app
click-ui-clickhouse.vercel.app

Please sign in to comment.