-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Expand file tree
/
Copy pathuseToolbarButton.ts
More file actions
52 lines (47 loc) · 1.48 KB
/
useToolbarButton.ts
File metadata and controls
52 lines (47 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
'use client';
import type * as React from 'react';
import { useButtonBase_unstable } from '@fluentui/react-button';
import type {
ToolbarButtonBaseProps,
ToolbarButtonBaseState,
ToolbarButtonProps,
ToolbarButtonState,
} from './ToolbarButton.types';
/**
* Given user props, defines default props for the Button, calls useButtonState and useChecked, and returns
* processed state.
* @param props - User provided props to the Button component.
* @param ref - User provided ref to be passed to the Button component.
*/
export const useToolbarButton_unstable = (
props: ToolbarButtonProps,
ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>,
): ToolbarButtonState => {
const { appearance = 'subtle', ...baseProps } = props;
const state = useToolbarButtonBase_unstable(baseProps, ref);
return {
appearance,
size: 'medium',
shape: 'rounded',
...state,
};
};
/**
* Base hook that builds Toolbar Button state for behavior and structure only.
* It does not provide any design-related defaults.
*
* @internal
* @param props - User provided props to the Button component.
* @param ref - User provided ref to be passed to the Button component.
*/
export const useToolbarButtonBase_unstable = (
props: ToolbarButtonBaseProps,
ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>,
): ToolbarButtonBaseState => {
const { vertical = false, ...buttonProps } = props;
const state = useButtonBase_unstable(buttonProps, ref);
return {
vertical,
...state,
};
};