Skip to content

Commit f71e6b9

Browse files
committed
chore(ui): improvement option dopdown for all page
1 parent 6ae49a6 commit f71e6b9

17 files changed

Lines changed: 93 additions & 39 deletions

File tree

ui/dashboard/src/components/dropdown/search.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const DropdownMenuSearch = forwardRef(
1111
{ value, onChange, className, ...props }: DropdownMenuSearchProps,
1212
ref: Ref<HTMLInputElement>
1313
) => (
14-
<div className="sticky top-0 flex items-center w-full px-3 py-[11.5px] gap-x-2 border-b border-gray-200 bg-white z-50">
14+
<div className="sticky top-0 flex items-center w-full px-3 py-0 sm:py-[11.5px] gap-x-2 border-b border-gray-200 bg-white z-50">
1515
<div className="flex-center size-5">
1616
<Icon icon={IconSearch} size="xs" color="gray-500" />
1717
</div>

ui/dashboard/src/components/tabs-link/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const TabsContent = React.forwardRef<
4848
>(({ className, ...props }, ref) => (
4949
<div
5050
ref={ref}
51-
className={cn('mt-4 flex flex-col flex-1', className)}
51+
className={cn('mt-2 sm:mt-4 flex flex-col flex-1', className)}
5252
{...props}
5353
/>
5454
));

ui/dashboard/src/elements/environment-editor-list/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ const EnvironmentEditorList = ({
7373

7474
return (
7575
<DropdownMenuWithSearch
76+
isExpand
7677
options={remainingEnvironmentsOptions}
7778
label={environmentLabel}
7879
placeholder={placeholder || t('select-environment')}

ui/dashboard/src/elements/name-with-tooltip/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const DefaultTrigger = forwardRef<HTMLDivElement, DefaultTriggerProps>(
3636
ref={ref}
3737
id={parentId}
3838
className={cn(
39-
'typo-para-medium text-gray-700',
39+
'relative typo-para-medium text-gray-700',
4040
{ 'text-primary-500 underline cursor-pointer': haveAction },
4141
className
4242
)}
@@ -112,6 +112,7 @@ const NameWithTooltip = ({
112112
window.addEventListener('resize', hasMoreThanMaxLines);
113113
return () => window.removeEventListener('resize', hasMoreThanMaxLines);
114114
}, [childrenId, maxLines]);
115+
console.log('isTruncate', isTruncate);
115116

116117
return (
117118
<Tooltip
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { ReactNode, useEffect, useRef, useState } from 'react';
2+
import { cn } from 'utils/style';
3+
import { Tooltip } from 'components/tooltip';
4+
5+
interface Props {
6+
text: ReactNode;
7+
maxLines?: number;
8+
className?: string;
9+
align?: 'start' | 'center' | 'end';
10+
}
11+
12+
const TruncateWithTooltip = ({
13+
text,
14+
maxLines = 2,
15+
className,
16+
align
17+
}: Props) => {
18+
const textRef = useRef<HTMLDivElement>(null);
19+
const [isTruncated, setIsTruncated] = useState(false);
20+
21+
useEffect(() => {
22+
const check = () => {
23+
const el = textRef.current;
24+
if (!el) return;
25+
setIsTruncated(el.scrollHeight > el.clientHeight);
26+
};
27+
check();
28+
window.addEventListener('resize', check);
29+
return () => window.removeEventListener('resize', check);
30+
}, [text, maxLines]);
31+
32+
const trigger = (
33+
<div
34+
ref={textRef}
35+
className={cn('break-all text-start', className)}
36+
style={{
37+
display: '-webkit-box',
38+
WebkitLineClamp: maxLines,
39+
WebkitBoxOrient: 'vertical',
40+
overflow: 'hidden'
41+
}}
42+
>
43+
{text}
44+
</div>
45+
);
46+
47+
return (
48+
<Tooltip
49+
align={align}
50+
content={<div style={{ wordBreak: 'break-all' }}>{text}</div>}
51+
hidden={!isTruncated}
52+
trigger={trigger}
53+
triggerCls="relative cursor-default select-text"
54+
/>
55+
);
56+
};
57+
58+
export default TruncateWithTooltip;

ui/dashboard/src/elements/variation-label/index.tsx

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { cn } from 'utils/style';
22
import { FlagVariationPolygon } from 'pages/feature-flags/collection-layout/elements';
3-
import NameWithTooltip from 'elements/name-with-tooltip';
3+
import TruncateWithTooltip from 'elements/truncate-with-tooltip';
44

55
const VariationLabel = ({
66
label,
@@ -11,31 +11,14 @@ const VariationLabel = ({
1111
index: number;
1212
className?: string;
1313
}) => {
14-
const id = `variation-label-${index}`;
15-
1614
return (
1715
<div className={cn('flex items-center gap-x-2 pl-0.5', className)}>
1816
<FlagVariationPolygon index={index} />
19-
20-
<NameWithTooltip
21-
id={id}
17+
<TruncateWithTooltip
18+
text={label}
2219
maxLines={1}
23-
content={
24-
<div className="flex items-center gap-x-2">
25-
<FlagVariationPolygon index={index} />
26-
<p>{label}</p>
27-
</div>
28-
}
2920
align="start"
30-
trigger={
31-
<NameWithTooltip.Trigger
32-
id={id}
33-
name={label}
34-
maxLines={1}
35-
className="-mt-0.5"
36-
haveAction={false}
37-
/>
38-
}
21+
className="-mt-0.5"
3922
/>
4023
</div>
4124
);

ui/dashboard/src/pages/audit-logs/elements/entity-type-dropdown/index.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,7 @@ const EntityTypeDropdown = memo(
116116
options={optionCustom}
117117
value={Number(entityType)}
118118
labelCustom={label}
119-
cleanable
120119
placeholder={placeholder}
121-
onClear={() =>
122-
onChangeFilters({
123-
entityType: undefined
124-
})
125-
}
126120
onChange={value =>
127121
onChangeFilters({
128122
entityType: +value

ui/dashboard/src/pages/audit-logs/page-content.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ const PageContent = () => {
142142
action={
143143
<>
144144
<EntityTypeDropdown
145-
className="w-fit [&>div>button]:!max-w-full sm:[&>div>button]:!max-w-[175px] [&>div>button]:!w-full"
145+
className="w-fit max-w-[120px] sm:max-w-full [&>div>button]:!max-w-full sm:[&>div>button]:!max-w-[175px] [&>div>button]:!w-full"
146146
isSystemAdmin={!!consoleAccount?.isSystemAdmin}
147147
entityType={filters?.entityType}
148148
onChangeFilters={onChangeFilters}

ui/dashboard/src/pages/experiments/experiments-modal/experiment-create-update/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ const ExperimentCreateUpdateModal = ({
557557
disabled={!!isEdit || disabled}
558558
hidden={isOpenCreateFlagModal}
559559
isLoading={isLoadingFeature}
560+
isExpand
560561
placeholder={t(`experiments.select-flag`)}
561562
label={
562563
featureFlagOptions.find(
@@ -607,9 +608,10 @@ const ExperimentCreateUpdateModal = ({
607608
<Form.Control>
608609
<Dropdown
609610
disabled={!!isEdit || disabled}
611+
isExpand
610612
placeholder={t(`experiments.select-variation`)}
611613
className="w-full [&>div>p]:truncate [&>div]:max-w-[calc(100%-36px)]"
612-
contentClassName="min-w-[502px]"
614+
contentClassName="sm:min-w-[502px]"
613615
options={variationOptions}
614616
value={field.value}
615617
onChange={field.onChange}
@@ -646,6 +648,7 @@ const ExperimentCreateUpdateModal = ({
646648
<Form.Control>
647649
<DropdownMenuWithSearch
648650
isMultiselect
651+
isExpand
649652
disabled={!!isEdit || disabled}
650653
hidden={isOpenCreateGoalModal}
651654
isLoading={isLoadingGoals}

ui/dashboard/src/pages/feature-flag-details/targeting/prerequisite-rule/condition.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ const ConditionForm = forwardRef(
9595
ref={ref}
9696
className="flex items-start sm:items-center w-full gap-x-0 sm:gap-x-4"
9797
>
98-
<div className="flex flex-col h-[210px] sm:h-full gap-2 items-center">
98+
<div className="flex flex-col h-[200px] sm:h-full gap-2 items-center">
9999
<div
100100
className={cn(
101101
'flex-center w-[42px] h-[26px] rounded-[3px] typo-para-small leading-[14px]',

0 commit comments

Comments
 (0)