Skip to content

feat: adopt calendar to mobile version #216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions src/components/CalendarView/Calendar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
$block: '.#{variables.$ns}calendar';

#{$block} {
--_--calendar-padding: var(--g-date-calendar-padding, 8px);
--_--calendar-padding-x: var(--g-date-calendar-padding-x, 16px);
--_--calendar-padding-y: var(--g-date-calendar-padding-y, 8px);
--_--calendar-day-size: var(--g-date-calendar-day-size, 28px);
--_--calendar-days-gap: var(--g-date-calendar-days-gap, 2px);

--_--calendar-width: calc(
7 * var(--_--calendar-day-size) + 6 * var(--_--calendar-days-gap) + 2 *
var(--_--calendar-padding)
var(--_--calendar-padding-x)
);
--_--calendar-grid-height: calc(
7 * var(--_--calendar-day-size) + 5 * var(--_--calendar-days-gap) +
var(--_--calendar-padding)
var(--_--calendar-padding-y)
);

display: inline-block;
Expand All @@ -33,16 +34,20 @@ $block: '.#{variables.$ns}calendar';

&__header {
display: flex;
justify-content: space-between;

padding: var(--_--calendar-padding) var(--_--calendar-padding) 0;
padding: var(--_--calendar-padding-y) var(--_--calendar-padding-x) 0;
}

&__years-label {
color: var(--g-color-text-secondary);
}

&__controls {
margin-inline-start: auto;
display: flex;
flex-shrink: 1;
justify-content: flex-end;
gap: var(--g-spacing-2);
}

&__control-icon {
Expand Down Expand Up @@ -71,7 +76,7 @@ $block: '.#{variables.$ns}calendar';
box-sizing: border-box;
width: 100%;
height: 100%;
padding: 0 var(--_--calendar-padding) var(--_--calendar-padding);
padding: 0 var(--_--calendar-padding-x) var(--_--calendar-padding-y);

@keyframes calendar-forward {
from {
Expand Down Expand Up @@ -239,6 +244,7 @@ $block: '.#{variables.$ns}calendar';

font-weight: var(--g-text-subheader-font-weight);
cursor: pointer;
text-transform: capitalize;

border-radius: 4px;
outline: none;
Expand Down Expand Up @@ -306,4 +312,8 @@ $block: '.#{variables.$ns}calendar';
background-color: var(--g-color-base-generic);
}
}

&__mode-label {
text-transform: capitalize;
}
}
8 changes: 5 additions & 3 deletions src/components/CalendarView/CalendarView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export const CalendarView = React.forwardRef<CalendarInstance, CalendarViewProps
state,
);

const buttonView = props.size === 'xl' ? 'outlined' : 'flat';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we should change button view according to the size property? I suggest u to use useMobile hook here


React.useImperativeHandle(ref, () => ({
focus() {
state.setFocused(true);
Expand All @@ -58,7 +60,7 @@ export const CalendarView = React.forwardRef<CalendarInstance, CalendarViewProps
style={props.style}
>
<div className={b('header')}>
<Button {...modeButtonProps} view="flat" size={props.size}>
<Button {...modeButtonProps} view={buttonView} size={props.size}>
{state.availableModes.indexOf(state.mode) + 1 ===
state.availableModes.length ? (
<span key="label" className={b('mode-label', b(`years-label`))}>
Expand All @@ -76,12 +78,12 @@ export const CalendarView = React.forwardRef<CalendarInstance, CalendarViewProps
)}
</Button>
<div className={b('controls')}>
<Button {...previousButtonProps} view="flat" size={props.size}>
<Button {...previousButtonProps} view={buttonView} size={props.size}>
<Button.Icon>
<ChevronLeft className={b('control-icon')} />
</Button.Icon>
</Button>
<Button {...nextButtonProps} view="flat" size={props.size}>
<Button {...nextButtonProps} view={buttonView} size={props.size}>
<Button.Icon>
<ChevronRight className={b('control-icon')} />
</Button.Icon>
Expand Down
Loading