Skip to content

Commit c4d747e

Browse files
GianoglioEnricoEnricoGianoglio
andauthored
feat(react-cap-theme): add react-combobox components (#648)
Co-authored-by: EnricoGianoglio <egianoglio@microsoft.com>
1 parent f64215f commit c4d747e

9 files changed

Lines changed: 938 additions & 0 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "add react-combobox components",
4+
"packageName": "@fluentui-contrib/react-cap-theme",
5+
"email": "egianoglio@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}

packages/react-cap-theme/.storybook/preview.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ const capTheme: Record<keyof Theme & keyof CAPTokens, string> = {
2020
colorNeutralStroke4Hover: '#e0e0e0',
2121
colorNeutralStroke4Pressed: '#d6d6d6',
2222
colorNeutralStroke4Selected: '#ebebeb',
23+
colorNeutralForeground5: '#616161',
24+
colorNeutralForeground5Hover: '#242424',
25+
colorNeutralForeground5Pressed: '#242424',
2326
};
2427

2528
const preview: Preview = {

packages/react-cap-theme/src/capStyleHooks.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ import type {
6767
} from '@fluentui/react-carousel';
6868
import { useCheckboxStyles } from './components/react-checkbox';
6969
import type { CheckboxState } from './components/react-checkbox';
70+
import {
71+
useComboboxStyles,
72+
useDropdownStyles,
73+
} from './components/react-combobox';
74+
import type { ComboboxState, DropdownState } from './components/react-combobox';
7075
import {
7176
useDialogActionsStyles,
7277
useDialogBodyStyles,
@@ -213,6 +218,9 @@ export const CAP_STYLE_HOOKS: NonNullable<
213218
useCompoundButtonStyles_unstable: (state) => {
214219
return useCompoundButtonStyles(state as CompoundButtonState);
215220
},
221+
useComboboxStyles_unstable: (state) => {
222+
return useComboboxStyles(state as ComboboxState);
223+
},
216224
useDialogActionsStyles_unstable: (state) => {
217225
return useDialogActionsStyles(state as DialogActionsState);
218226
},
@@ -242,6 +250,9 @@ export const CAP_STYLE_HOOKS: NonNullable<
242250
useDrawerHeaderTitleStyles_unstable: (state) => {
243251
return useDrawerHeaderTitleStyles(state as DrawerHeaderTitleState);
244252
},
253+
useDropdownStyles_unstable: (state) => {
254+
return useDropdownStyles(state as DropdownState);
255+
},
245256
useImageStyles_unstable: (state) => {
246257
return useImageStyles(state as ImageState);
247258
},
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import type {
2+
ComboboxProps as BaseProps,
3+
ComboboxSlots as BaseSlots,
4+
ComboboxState as BaseState,
5+
} from '@fluentui/react-combobox';
6+
import type {
7+
ComponentProps,
8+
ComponentState,
9+
Slot,
10+
} from '@fluentui/react-utilities';
11+
12+
/**
13+
* Slot configuration for the Combobox component.
14+
* Adds the SP-specific contentBefore slot. The listbox slot is inherited
15+
* from Fluent and restyled in `useComboboxStyles`.
16+
* @alpha
17+
*/
18+
export type ComboboxSlots = BaseSlots & {
19+
/**
20+
* Element before the input text, e.g. an icon or avatar.
21+
*/
22+
contentBefore?: Slot<'span'>;
23+
};
24+
25+
/**
26+
* Properties for configuring the Combobox component.
27+
* @alpha
28+
*/
29+
export type ComboboxProps = ComponentProps<
30+
Pick<ComboboxSlots, 'contentBefore'>
31+
> &
32+
Omit<BaseProps, 'color'> & {
33+
/**
34+
* The color variant.
35+
*
36+
* - 'brand' (default): Primary emphasis using brand colors.
37+
* - 'neutral': Secondary emphasis using neutral colors.
38+
*
39+
* @default 'brand'
40+
*/
41+
// FIXME: Must not graduate to beta. Style implementation references Fluent tokens directly.
42+
// `color` and `NeutralThemeProvider` solve the same brand/neutral switching problem at different
43+
// levels of the stack with no defined interaction. Graduating locks in an API contract that may
44+
// need to change once a proper token-based theming approach is defined.
45+
color?: 'neutral' | 'brand';
46+
};
47+
48+
/**
49+
* State used in rendering the Combobox component.
50+
* @alpha
51+
*/
52+
export type ComboboxState = ComponentState<ComboboxSlots> &
53+
Omit<BaseState, 'components'> &
54+
Required<Pick<ComboboxProps, 'color'>>;

0 commit comments

Comments
 (0)