Skip to content

Commit 63cf53a

Browse files
committed
feat(Text): add text placeholder
1 parent a1a4245 commit 63cf53a

File tree

3 files changed

+67
-21
lines changed

3 files changed

+67
-21
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@cube-dev/ui-kit": patch
3+
---
4+
5+
Add `Text.Placeholder` variant with disabled opacity styling. This new text variant is useful for displaying placeholder content with reduced visual emphasis.
6+
7+

src/components/content/Text.tsx

Lines changed: 58 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -99,27 +99,66 @@ const Text = forwardRef(function CubeText(allProps: CubeTextProps, ref) {
9999
);
100100
});
101101

102-
const _Text = Object.assign(Text, {
103-
Minor: forwardRef(function MinorText(props: CubeTextProps, ref) {
104-
return <Text ref={ref} color="#minor" {...props} />;
105-
}),
106-
Danger: forwardRef(function DangerText(props: CubeTextProps, ref) {
107-
return <Text ref={ref} role="alert" color="#danger-text" {...props} />;
108-
}),
109-
Success: forwardRef(function SuccessText(props: CubeTextProps, ref) {
110-
return <Text ref={ref} color="#success-text" {...props} />;
111-
}),
112-
Strong: forwardRef(function StrongText(props: CubeTextProps<'strong'>, ref) {
113-
return <Text ref={ref} as="strong" preset="strong" {...props} />;
114-
}),
115-
Emphasis: forwardRef(function StrongText(props: CubeTextProps<'em'>, ref) {
116-
return <Text ref={ref} as="em" preset="em" {...props} />;
117-
}),
118-
Selection: forwardRef(function SelectionText(props: CubeTextProps, ref) {
119-
return <Text ref={ref} color="#dark" fill="#note.30" {...props} />;
120-
}),
102+
const MinorText = tasty(Text, {
103+
styles: {
104+
color: '#minor',
105+
},
106+
});
107+
108+
const DangerText = tasty(Text, {
109+
role: 'alert',
110+
styles: {
111+
color: '#danger-text',
112+
},
113+
});
114+
115+
const SuccessText = tasty(Text, {
116+
styles: {
117+
color: '#success-text',
118+
},
119+
});
120+
121+
const StrongText = tasty(Text, {
122+
as: 'strong',
123+
preset: 'strong',
121124
});
122125

126+
const EmphasisText = tasty(Text, {
127+
as: 'em',
128+
preset: 'em',
129+
});
130+
131+
const SelectionText = tasty(Text, {
132+
styles: {
133+
color: '#dark',
134+
fill: '#note.30',
135+
},
136+
});
137+
138+
const PlaceholderText = tasty(Text, {
139+
styles: {
140+
opacity: '$disabled-opacity',
141+
},
142+
});
143+
144+
const _Text = Object.assign(Text, {
145+
Minor: MinorText,
146+
Danger: DangerText,
147+
Success: SuccessText,
148+
Strong: StrongText,
149+
Emphasis: EmphasisText,
150+
Selection: SelectionText,
151+
Placeholder: PlaceholderText,
152+
}) as typeof Text & {
153+
Minor: typeof MinorText;
154+
Danger: typeof DangerText;
155+
Success: typeof SuccessText;
156+
Strong: typeof StrongText;
157+
Emphasis: typeof EmphasisText;
158+
Selection: typeof SelectionText;
159+
Placeholder: typeof PlaceholderText;
160+
};
161+
123162
_Text.displayName = 'Text';
124163

125164
export { _Text as Text };

src/components/fields/FilterPicker/FilterPicker.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,13 +1567,13 @@ export const InForm = () => {
15671567
export const ComplexExample: Story = {
15681568
args: {
15691569
label: 'Advanced Filter System',
1570-
placeholder: 'Apply filters...',
15711570
selectionMode: 'multiple',
15721571
isCheckable: true,
15731572
searchPlaceholder: 'Search all filters...',
15741573
width: '30x',
15751574
renderSummary: ({ selectedKeys, selectedLabels }) => {
1576-
if (selectedKeys.length === 0) return null;
1575+
if (selectedKeys.length === 0)
1576+
return <Text.Placeholder>Apply filters...</Text.Placeholder>;
15771577
if (selectedKeys.length === 1) return `1 filter: ${selectedLabels[0]}`;
15781578
if (selectedKeys.length <= 3)
15791579
return `${selectedKeys.length} filters: ${selectedLabels.join(', ')}`;

0 commit comments

Comments
 (0)