Skip to content

Commit

Permalink
Allow config of internal padding and range separator size in DateField
Browse files Browse the repository at this point in the history
  • Loading branch information
federico-ercoles committed Apr 22, 2024
1 parent 52cd4af commit f36f64b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/bento-design-system/src/DateField/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import { Children } from "../util/Children";
export type DateFieldConfig = {
radius: BorderRadiusConfig;
padding: NonNullable<BentoSprinkles["padding"]>;
internalPadding: NonNullable<BentoSprinkles["padding"]>;
elevation: "none" | "small" | "medium" | "large";
rangeSeparatorSize: IconProps["size"];
monthYearLabelSize: LabelProps["size"];
dayOfWeekLabelSize: LabelProps["size"];
previousMonthIcon: (props: IconProps) => Children;
Expand Down
7 changes: 5 additions & 2 deletions packages/bento-design-system/src/DateField/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ function DateField({ fieldProps }: { fieldProps: AriaDateFieldOptions<CalendarDa

export function Input(props: Props) {
const config = useBentoConfig().input;
const dateFieldConfig = useBentoConfig().dateField;

const { observe: rightAccessoryRef, width: rightAccessoryWidth } = useDimensions({
// This is needed to include the padding in the width
Expand Down Expand Up @@ -146,10 +147,12 @@ export function Input(props: Props) {
{props.type === "single" ? (
<DateField fieldProps={props.fieldProps} />
) : (
<Columns space={16}>
<Columns space={dateFieldConfig.internalPadding} alignY="stretch">
<DateField fieldProps={props.fieldProps.start} />
<Column width="content">
<IconMinus size={24} />
<Box display="flex" height="full" alignItems="center">
<IconMinus size={dateFieldConfig.rangeSeparatorSize} />
</Box>
</Column>
<DateField fieldProps={props.fieldProps.end} />
</Columns>
Expand Down
2 changes: 2 additions & 0 deletions packages/bento-design-system/src/util/defaultConfigs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,9 @@ export const tooltip: TooltipConfig = {
export const dateField: DateFieldConfig = {
radius: 24,
padding: 24,
internalPadding: 16,
elevation: "medium",
rangeSeparatorSize: 24,
monthYearLabelSize: "large",
dayOfWeekLabelSize: "large",
previousMonthIcon: IconChevronLeft,
Expand Down
4 changes: 4 additions & 0 deletions packages/bento-design-system/stories/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export const BentoProvider = createBentoProvider(
pagination: {
itemsPerPageOptions: [5, 10, 20, 50],
},
dateField: {
internalPadding: 8,
rangeSeparatorSize: 16,
},
},
sprinkles
);
Expand Down

0 comments on commit f36f64b

Please sign in to comment.