Skip to content

Commit

Permalink
feat(date-range-picker): mini
Browse files Browse the repository at this point in the history
  • Loading branch information
RyushiAok committed Jan 9, 2025
1 parent a782260 commit d6c5a2a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/styles/bases/date-range-picker.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@ const BORDER_WIDTH = "1px";
const baseBodyStyle = style({
borderRadius: THEME.spacing.xs2,
boxSizing: "border-box",
padding: `calc(${THEME.spacing.xs} - ${BORDER_WIDTH}) ${THEME.spacing.xs}`,
fontSize: THEME.fontSize.sm,
display: "flex",
alignItems: "center",
justifyContent: "space-between",
});

export const variantStyles = styleVariants({
regular: {
padding: `calc(${THEME.spacing.xs} - ${BORDER_WIDTH}) ${THEME.spacing.xs}`,
},
mini: {
padding: `1px ${THEME.spacing.xs2}`,
},
});

export const bodyStyle = styleVariants({
active: [
baseBodyStyle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,16 @@ IsDirectionFixed.parameters = {
},
};

export const Mini = Template.bind({});
Mini.args = {
modelValue: {
start: new Date(2020, 0, 15),
end: new Date(2020, 1, 15),
},
isDirectionFixed: true,
variant: "mini",
};

const _formatDateJp = (date: Date) =>
`${date.getFullYear()}${date.getMonth() + 1}${date.getDate()}日`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<button
type="button"
:class="[
styles.variantStyles[variant],
styles.bodyStyle[disabled ? 'disabled' : 'active'],
styles.widthStyle[expand ? 'expanded' : 'default'],
inputBorderStyle[borderState],
Expand Down Expand Up @@ -223,6 +224,11 @@ const props = defineProps({
type: String,
required: false,
},
variant: {
type: String as PropType<"regular" | "mini">,
required: false,
default: "regular",
},
/**
* カレンダー(Popup)の開閉状態を指定します。
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type Props = BaseProps & {
selectBoxOptions?: DateRangePickerSelectBoxOption[];
selectBoxValue?: string;
isDirectionFixed?: boolean;
variant?: "regular" | "mini";
error?: boolean;
_today?: Date;
onChangeDateRange?: (dateRange: DateRange) => void;
Expand All @@ -63,6 +64,7 @@ const DateRangePicker: FC<Props> = ({
selectBoxOptions,
selectBoxValue,
isDirectionFixed = false,
variant = "regular",
error,
_today,
onChangeDateRange,
Expand Down Expand Up @@ -233,6 +235,7 @@ const DateRangePicker: FC<Props> = ({
className={clsx(
className,
styles.bodyStyle[disabled ? "disabled" : "active"],
styles.variantStyles[variant],
styles.widthStyle[expand ? "expanded" : "default"],
inputBorderStyle[borderStyle]
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ export const InitialValueStart: Story = {
},
};

export const Mini: Story = {
args: {
dateRange: {
start: new Date(2000, 0, 15),
end: null,
},
variant: "mini",
},
};

export const Playground: Story = {
args: {
selectBoxOptions: [
Expand Down

0 comments on commit d6c5a2a

Please sign in to comment.