diff --git a/packages/demo-app/src/examples/ButtonGroupExample.tsx b/packages/demo-app/src/examples/ButtonGroupExample.tsx new file mode 100644 index 0000000000..045b27b131 --- /dev/null +++ b/packages/demo-app/src/examples/ButtonGroupExample.tsx @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Palantir Technologies, Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as React from "react"; + +import { Button, ButtonGroup, Intent } from "@blueprintjs/core"; + +import { ExampleCard } from "./ExampleCard"; + +export class ButtonGroupExample extends React.PureComponent { + public render() { + return ( +
+ + {Object.values(Intent).map(intent => ( + +
+ ); + } +} diff --git a/packages/demo-app/src/examples/Examples.tsx b/packages/demo-app/src/examples/Examples.tsx index 2349a1fecf..55c3c67a8d 100644 --- a/packages/demo-app/src/examples/Examples.tsx +++ b/packages/demo-app/src/examples/Examples.tsx @@ -21,6 +21,7 @@ import { Classes } from "@blueprintjs/core"; import { BreadcrumbExample } from "./BreadcrumbExample"; import { ButtonExample } from "./ButtonExample"; +import { ButtonGroupExample } from "./ButtonGroupExample"; import { CalloutExample } from "./CalloutExample"; import { CheckboxRadioExample } from "./CheckboxRadioExample"; import { DatePickerExample } from "./DatePickerExample"; @@ -51,6 +52,7 @@ export class Examples extends React.PureComponent {
+ diff --git a/packages/docs-app/src/examples/core-examples/buttonGroupExample.tsx b/packages/docs-app/src/examples/core-examples/buttonGroupExample.tsx index 6f4bb7331b..6865ab0d78 100644 --- a/packages/docs-app/src/examples/core-examples/buttonGroupExample.tsx +++ b/packages/docs-app/src/examples/core-examples/buttonGroupExample.tsx @@ -16,15 +16,18 @@ import * as React from "react"; -import { Alignment, AnchorButton, Button, ButtonGroup, H5, Switch } from "@blueprintjs/core"; -import { Example, handleBooleanChange, IExampleProps } from "@blueprintjs/docs-theme"; +import { Alignment, AnchorButton, Button, ButtonGroup, Classes, H5, Icon, Intent, Switch } from "@blueprintjs/core"; +import { Example, handleBooleanChange, handleValueChange, IExampleProps } from "@blueprintjs/docs-theme"; +import { Tooltip2 } from "@blueprintjs/popover2"; import { AlignmentSelect } from "./common/alignmentSelect"; +import { IntentSelect } from "./common/intentSelect"; export interface IButtonGroupExampleState { alignText: Alignment; fill: boolean; iconOnly: boolean; + intent: Intent; minimal: boolean; large: boolean; vertical: boolean; @@ -35,6 +38,7 @@ export class ButtonGroupExample extends React.PureComponent this.setState({ iconOnly })); + private handleIntentChange = handleValueChange((intent: Intent) => this.setState({ intent })); + private handleLargeChange = handleBooleanChange(large => this.setState({ large })); private handleMinimalChange = handleBooleanChange(minimal => this.setState({ minimal })); @@ -51,7 +57,29 @@ export class ButtonGroupExample extends React.PureComponent this.setState({ vertical })); public render() { - const { iconOnly, ...bgProps } = this.state; + const { iconOnly, intent, ...bgProps } = this.state; + // props for every button in the group + const buttonProps = { intent }; + + const intentLabelInfo = ( + + Intents are set individually on each button
+ in the group, not the ButtonGroup wrapper. + + } + placement="top" + minimal={true} + > + + Intent{" "} + + + + +
+ ); const options = ( <>
Props
@@ -59,6 +87,7 @@ export class ButtonGroupExample extends React.PureComponent +
Example
@@ -69,11 +98,14 @@ export class ButtonGroupExample extends React.PureComponent {/* set `minWidth` so `alignText` will have an effect when vertical */} - - - - {!iconOnly && "Options"} - +