Skip to content

Commit baf4f1e

Browse files
committed
Add example to docs
1 parent d545b4a commit baf4f1e

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

packages/docs-app/src/examples/core-examples/textAreaExample.tsx

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@ import * as React from "react";
1919
import {
2020
AnchorButton,
2121
ControlGroup,
22+
FormGroup,
2223
H5,
24+
HTMLSelect,
2325
Intent,
2426
type Size,
2527
Switch,
2628
TextArea,
2729
type TextAreaProps,
2830
Tooltip,
2931
} from "@blueprintjs/core";
30-
import { Example, type ExampleProps, handleBooleanChange } from "@blueprintjs/docs-theme";
32+
import { Example, type ExampleProps, handleBooleanChange, handleValueChange } from "@blueprintjs/docs-theme";
3133

3234
import { PropCodeTooltip } from "../../common/propCodeTooltip";
3335

@@ -44,6 +46,7 @@ export const TextAreaExample: React.FC<ExampleProps> = props => {
4446
const [disabled, setDisabled] = React.useState(false);
4547
const [intent, setIntent] = React.useState<Intent>(Intent.NONE);
4648
const [readOnly, setReadOnly] = React.useState(false);
49+
const [resize, setResize] = React.useState<undefined | "none" | "vertical" | "horizontal" | "both">(undefined);
4750
const [size, setSize] = React.useState<Size>("medium");
4851
const [value, setValue] = React.useState(INTITIAL_CONTROLLED_TEXT);
4952

@@ -74,6 +77,7 @@ export const TextAreaExample: React.FC<ExampleProps> = props => {
7477
<AnchorButton disabled={!controlled} icon="reset" onClick={resetControlledText} />
7578
</Tooltip>
7679
</ControlGroup>
80+
<ResizeSelect label="Resize" onChange={setResize} value={resize} />
7781
</>
7882
);
7983

@@ -82,6 +86,7 @@ export const TextAreaExample: React.FC<ExampleProps> = props => {
8286
disabled,
8387
intent,
8488
readOnly,
89+
resize,
8590
size,
8691
};
8792

@@ -96,3 +101,28 @@ export const TextAreaExample: React.FC<ExampleProps> = props => {
96101
</Example>
97102
);
98103
};
104+
105+
const RESIZE_OPTIONS: Array<{ label: string; value: TextAreaProps["resize"] }> = [
106+
{ label: "Default", value: undefined },
107+
{ label: "None", value: "none" },
108+
{ label: "Vertical", value: "vertical" },
109+
{ label: "Horizontal", value: "horizontal" },
110+
{ label: "Both", value: "both" },
111+
];
112+
113+
export interface ResizeSelectProps {
114+
label?: React.ReactNode;
115+
onChange: (resize: TextAreaProps["resize"]) => void;
116+
value: TextAreaProps["resize"];
117+
}
118+
119+
function ResizeSelect({ label, onChange, value }: ResizeSelectProps) {
120+
const handleChange = handleValueChange(onChange);
121+
return (
122+
<FormGroup label={label}>
123+
<ControlGroup>
124+
<HTMLSelect value={value} onChange={handleChange} options={RESIZE_OPTIONS} fill={true} />
125+
</ControlGroup>
126+
</FormGroup>
127+
);
128+
}

0 commit comments

Comments
 (0)