From 1d9140de22a3cec384f20bb482213e476ce29dd8 Mon Sep 17 00:00:00 2001 From: Adi Dahiya Date: Fri, 4 Nov 2022 15:06:51 -0700 Subject: [PATCH 1/2] WIP add DateRangeInput2 fill prop --- .../src/components/date-range-input2/dateRangeInput2.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/datetime2/src/components/date-range-input2/dateRangeInput2.tsx b/packages/datetime2/src/components/date-range-input2/dateRangeInput2.tsx index 051098228c..c2eefd20e4 100644 --- a/packages/datetime2/src/components/date-range-input2/dateRangeInput2.tsx +++ b/packages/datetime2/src/components/date-range-input2/dateRangeInput2.tsx @@ -92,6 +92,11 @@ export interface DateRangeInput2Props extends DatePickerBaseProps, DateFormatPro */ disabled?: boolean; + /** + * Whether the component should take up the full width of its container. + */ + fill?: boolean; + /** * Props to pass to the end-date [input group](#core/components/text-inputs.input-group). * `disabled` and `value` will be ignored in favor of the top-level props on this component. From 8e8e49fff7fc508670f85fa6a64bc0e9d25ccce9 Mon Sep 17 00:00:00 2001 From: Adi Dahiya Date: Fri, 4 Nov 2022 16:29:12 -0700 Subject: [PATCH 2/2] [datetime2] feat(DateRangeInput2): support 'fill' prop --- .../date-range-input2/dateRangeInput2.tsx | 7 +- ...tkeyTester.tsx => hotkeyTesterExample.tsx} | 6 +- .../src/examples/core-examples/index.ts | 2 +- .../datetime2-examples/dateInput2Example.tsx | 60 +++++---- .../dateRangeInput2Example.tsx | 124 +++++++++++------- packages/docs-app/src/styles/_examples.scss | 57 ++++---- 6 files changed, 159 insertions(+), 97 deletions(-) rename packages/docs-app/src/examples/core-examples/{hotkeyTester.tsx => hotkeyTesterExample.tsx} (91%) diff --git a/packages/datetime2/src/components/date-range-input2/dateRangeInput2.tsx b/packages/datetime2/src/components/date-range-input2/dateRangeInput2.tsx index c2eefd20e4..5780d4b480 100644 --- a/packages/datetime2/src/components/date-range-input2/dateRangeInput2.tsx +++ b/packages/datetime2/src/components/date-range-input2/dateRangeInput2.tsx @@ -374,13 +374,15 @@ export class DateRangeInput2 extends AbstractPureComponent2) => { - const { popoverProps = {} } = this.props; + const { fill, popoverProps = {} } = this.props; const { targetTagName = "div" } = popoverProps; return React.createElement( targetTagName, { ...targetProps, - className: classNames(CoreClasses.CONTROL_GROUP, targetProps.className), + className: classNames(CoreClasses.CONTROL_GROUP, targetProps.className, { + [CoreClasses.FILL]: fill, + }), }, this.renderInputGroup(Boundary.START), this.renderInputGroup(Boundary.END), @@ -395,6 +397,7 @@ export class DateRangeInput2 extends AbstractPureComponent2 { - public state: IHotkeyTesterState = { +export class HotkeyTesterExample extends React.PureComponent { + public state: HotkeyTesterState = { combo: null, }; diff --git a/packages/docs-app/src/examples/core-examples/index.ts b/packages/docs-app/src/examples/core-examples/index.ts index fd22838f98..c139f4439e 100644 --- a/packages/docs-app/src/examples/core-examples/index.ts +++ b/packages/docs-app/src/examples/core-examples/index.ts @@ -38,7 +38,7 @@ export * from "./fileInputExample"; export * from "./focusExample"; export * from "./formGroupExample"; export * from "./hotkeyPiano"; -export * from "./hotkeyTester"; +export * from "./hotkeyTesterExample"; export { HotkeysTarget2Example } from "./hotkeysTarget2Example"; export * from "./iconExample"; export * from "./menuExample"; diff --git a/packages/docs-app/src/examples/datetime2-examples/dateInput2Example.tsx b/packages/docs-app/src/examples/datetime2-examples/dateInput2Example.tsx index 50cab9500e..58012ef738 100644 --- a/packages/docs-app/src/examples/datetime2-examples/dateInput2Example.tsx +++ b/packages/docs-app/src/examples/datetime2-examples/dateInput2Example.tsx @@ -17,7 +17,7 @@ import classNames from "classnames"; import * as React from "react"; -import { Classes, H5, Icon, Switch, Tag } from "@blueprintjs/core"; +import { Classes, Code, H5, Icon, Switch, Tag } from "@blueprintjs/core"; import { DateFormatProps, TimePrecision } from "@blueprintjs/datetime"; import { DateInput2 } from "@blueprintjs/datetime2"; import { Example, ExampleProps, handleBooleanChange, handleValueChange } from "@blueprintjs/docs-theme"; @@ -139,10 +139,12 @@ export class DateInput2Example extends React.PureComponent -
Props
+
Behavior props
+ +
Date picker props
+ + + + +
Input appearance props
+ + + + + + + + rightElement is {showRightElement ? "defined" : "undefined"} + + } + > + + + + +
Time picker props
- -
Appearance props
- - - - - - -
- TimezoneSelect props + Timezone select props
diff --git a/packages/docs-app/src/examples/datetime2-examples/dateRangeInput2Example.tsx b/packages/docs-app/src/examples/datetime2-examples/dateRangeInput2Example.tsx index 6aed72f78b..9ebac3d5a6 100644 --- a/packages/docs-app/src/examples/datetime2-examples/dateRangeInput2Example.tsx +++ b/packages/docs-app/src/examples/datetime2-examples/dateRangeInput2Example.tsx @@ -21,6 +21,7 @@ import { DateFormatProps, DateRange, TimePrecision } from "@blueprintjs/datetime import { DateRangeInput2 } from "@blueprintjs/datetime2"; import { Example, ExampleProps, handleBooleanChange, handleValueChange } from "@blueprintjs/docs-theme"; +import { PropCodeTooltip } from "../../common/propCodeTooltip"; import { PrecisionSelect } from "../datetime-examples/common/precisionSelect"; import { DateFnsDateRange } from "./dateFnsDate"; import { DATE_FNS_FORMATS, DateFnsFormatSelector } from "./dateFnsFormatSelector"; @@ -38,6 +39,7 @@ export interface DateRangeInput2ExampleState { contiguousCalendarMonths: boolean; disabled: boolean; enableTimePicker: boolean; + fill: boolean; format: DateFormatProps; range: DateRange; reverseMonthAndYearMenus: boolean; @@ -56,6 +58,7 @@ export class DateRangeInput2Example extends React.PureComponent this.setState({ disabled })); + private toggleFill = handleBooleanChange(fill => this.setState({ fill })); + private toggleReverseMonthAndYearMenus = handleBooleanChange(reverseMonthAndYearMenus => this.setState({ reverseMonthAndYearMenus }), ); @@ -128,65 +133,96 @@ export class DateRangeInput2Example extends React.PureComponent -
Props
- - - +
Behavior props
+ + + + + + + +
Date range picker props
+ + + + + + + + + + + + - - - - - - + +
Input appearance props
+ + + + + + + + +
Time picker props
+ - + + + ); } diff --git a/packages/docs-app/src/styles/_examples.scss b/packages/docs-app/src/styles/_examples.scss index e252a384e7..9fff8d4798 100644 --- a/packages/docs-app/src/styles/_examples.scss +++ b/packages/docs-app/src/styles/_examples.scss @@ -10,9 +10,9 @@ @return '[data-page-id#{$comparator}"#{$ref}"]'; } -// Generate a selector for a React example by name -@function example($NameExample, $comparator: "=") { - @return '[data-example-id#{$comparator}"#{$NameExample}"]'; +// Generate a selector for a React component example by name +@function example($ComponentName, $comparator: "=") { + @return '[data-example-id#{$comparator}"#{$ComponentName}Example"]'; } // Specific example customizations @@ -32,13 +32,13 @@ width: $pt-grid-size * 35; } -#{example("ButtonsExample")} { +#{example("Buttons")} { .docs-wiggle { animation: docs-wiggle-rotate $pt-transition-duration $pt-transition-ease infinite; } } -#{example("EditableTextExample")} { +#{example("EditableText")} { .docs-example { display: block; } @@ -48,7 +48,7 @@ } } -#{example("FormGroupExample")} { +#{example("FormGroup")} { .docs-example { flex-direction: column; } @@ -58,11 +58,11 @@ } } -#{example("MenuExample")} .#{$ns}-menu { +#{example("Menu")} .#{$ns}-menu { max-width: 280px; } -#{example("DialogExample")} .docs-example-options { +#{example("Dialog")} .docs-example-options { max-width: 260px; } @@ -70,7 +70,7 @@ min-height: 150px; } -#{example("TagExample")} { +#{example("Tag")} { .docs-example { flex-direction: column; } @@ -214,7 +214,7 @@ } } -#{example("OverflowListExample")} { +#{example("OverflowList")} { .#{$ns}-card { margin: 0; min-width: $pt-grid-size * 7; @@ -261,8 +261,8 @@ height: 200%; } -#{example("Popover2Example")}, -#{example("PopoverExample")} { +#{example("Popover2")}, +#{example("Popover")} { .docs-example { display: block; max-height: 785px; @@ -287,8 +287,8 @@ } } -#{example("Popover2DismissExample")}, -#{example("PopoverDismissExample")} { +#{example("Popover2Dismiss")}, +#{example("PopoverDismiss")} { height: 220px; .docs-reopen-message { @@ -311,8 +311,8 @@ } } -#{example("PanelStack2Example")}, -#{example("PanelStackExample")} { +#{example("PanelStack2")}, +#{example("PanelStack")} { .docs-panel-stack-example { box-shadow: $pt-elevation-shadow-0; height: 240px; @@ -486,8 +486,8 @@ line-height: $pt-navbar-height; } -#{example("Tooltip2Example")}, -#{example("TooltipExample")} { +#{example("Tooltip2")}, +#{example("Tooltip")} { .docs-example { flex-direction: column; @@ -497,14 +497,14 @@ } } -#{example("ButtonGroupExample")}, -#{example("ButtonGroupPopoverExample")} { +#{example("ButtonGroup")}, +#{example("ButtonGroupPopover")} { .docs-example > * { margin: 0; } } -#{example("ToastExample")} { +#{example("Toast")} { .docs-example { // necessary for inline Toaster (usePortal={false}) position: relative; @@ -523,7 +523,7 @@ justify-content: center; } - #{example("TimezoneSelectExample")} .docs-example { + #{example("TimezoneSelect")} .docs-example { flex-direction: row; } } @@ -533,7 +533,7 @@ align-items: center; } -#{example("DateInputExample")} { +#{example("DateInput")} { .docs-example > * { margin: 0 0 20px; } @@ -543,15 +543,22 @@ // DATETIME2 // -#{example("DateInput2Example")} { +#{example("DateInput2")} { .#{$ns}-date-input { // should not grow in vertical direction when fill={true} flex-grow: 0; - margin: 0; min-width: 300px; } } +// these component examples have a "fill" prop option, which doesn't work nicely with the default margin +#{example("DateInput2")}, #{example("DateRangeInput2")} { + .docs-example > * { + margin: 0; + } +} + + // // TABLE //