Skip to content
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

feat: calendar component #823

Merged
merged 54 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
c49b425
Merge pull request #783 from Trendyol/next
leventozen Jan 25, 2024
b6d0b51
build: continue if component is not custom element
dilandoogan Apr 4, 2024
d00e308
feat(calendar): calculate calendar days and render calendar component
dilandoogan Mar 31, 2024
b8bb21b
refactor(calendar): changing names to be understandable
dilandoogan Apr 1, 2024
ab82af3
refactor(calendar): review updates
dilandoogan Apr 4, 2024
bad4dba
Merge branch 'next' into calendar
dilandoogan Apr 4, 2024
1de1de3
refactor(calendar): improve excluded files for build
dilandoogan Apr 5, 2024
ce7b1a2
feat(calendar): set months and years view for calendar
dilandoogan Apr 14, 2024
d8fbb22
feat(calendar): trigger event when new date selected
dilandoogan Apr 15, 2024
1c0765c
feat(calendar): add calendar component basic story
dilandoogan Apr 15, 2024
21cef1a
feat(calendar): adding multipe type option for calendar
dilandoogan Apr 16, 2024
2360713
feat(calendar): fix multiple type select view
dilandoogan Apr 16, 2024
8fdb5ec
feat(calendar): disable user to select from disabled dates
dilandoogan Apr 17, 2024
701c7ec
feat(calendar): disable user to select a date before min date or afte…
dilandoogan Apr 17, 2024
de36d9a
Merge branch 'next' into calendar
buseselvi Apr 18, 2024
9718397
Merge remote-tracking branch 'origin/calendar' into calendar
dilandoogan Apr 22, 2024
2d61a72
feat(calendar): show previous month and next month days on calendar
dilandoogan Apr 22, 2024
09e1e65
Merge branch 'next' into calendar
buseselvi Apr 25, 2024
71c176c
feat(calendar): handle disabled dates and min max date properly
dilandoogan Apr 28, 2024
02a82f3
Merge branch 'next' into calendar
dilandoogan Apr 28, 2024
6bedf08
Merge remote-tracking branch 'origin/calendar' into calendar
dilandoogan Apr 28, 2024
5c8b11c
Merge branch 'next' into calendar
dilandoogan May 2, 2024
db3ae96
feat(calendar): changing calendarDate type implementations and first…
dilandoogan May 2, 2024
644d139
Merge branch 'next' into calendar
AykutSarac May 8, 2024
980c4d4
feat(calendar): adding all stories for calendar
dilandoogan May 11, 2024
f47db06
Merge branch 'next' into calendar
buseselvi May 13, 2024
ef348bb
feat(calendar): run prettier
dilandoogan May 13, 2024
615fa60
feat(calendar): design fixes
dilandoogan May 15, 2024
4d82c50
feat(calendar): design fixes and type adding for calendar view and ca…
dilandoogan May 15, 2024
ad79bfd
feat(calendar): change medium button vertical padding
dilandoogan May 15, 2024
83d4816
adding hover class to days
dilandoogan May 19, 2024
c4edfad
feat(calendar): make color white if other month date is selected
dilandoogan May 19, 2024
f0a1800
Merge branch 'next' into calendar
buseselvi May 20, 2024
a7ab20d
feat(calendar): format with prettier
dilandoogan May 20, 2024
0f7b0b4
feat(calendar): dont give hover to disabled dates
dilandoogan May 20, 2024
ec7d7a6
feat(calendar): dont allow cursor on disabled dates
dilandoogan May 20, 2024
f48e99e
remove unused important
dilandoogan May 22, 2024
8c0fbc8
feat(calendar): rendering days as button
dilandoogan Jun 10, 2024
8d41396
Merge branch 'next' into calendar
buseselvi Jun 10, 2024
b243f94
feat(calendar): run prettier
dilandoogan Jun 11, 2024
6cc87d9
feat(calendar): styling fix
dilandoogan Jun 11, 2024
0488ab4
feat(calendar): run prettier
dilandoogan Jun 11, 2024
5206a03
feat(calendar): accesibility fix
dilandoogan Jun 12, 2024
5102bf2
feat(calendar): run prettier
dilandoogan Jun 12, 2024
3a1d76a
feat(calendar): run prettier
dilandoogan Jun 12, 2024
69d7de2
adding --bl-button-focus-border-color color for calendar
dilandoogan Jun 13, 2024
99b270a
self review improvements
dilandoogan Jun 13, 2024
e9549e6
review updates
dilandoogan Jun 13, 2024
bf02254
Update src/components/calendar/bl-calendar.ts
AykutSarac Jun 14, 2024
37734f6
Update src/components/calendar/bl-calendar.ts
AykutSarac Jun 14, 2024
2c3668b
Merge branch 'next' into calendar
AykutSarac Jun 14, 2024
8e64712
review updates
dilandoogan Jun 24, 2024
6e7ac56
selecting disabled dates bug fix
dilandoogan Jun 25, 2024
b7885af
event name fix
dilandoogan Jun 27, 2024
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
1 change: 1 addition & 0 deletions commitlint.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module.exports = {
"textarea",
"popover",
"notification",
"calendar",
"table",
"split-button",
],
Expand Down
2 changes: 1 addition & 1 deletion custom-elements-manifest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { parse } from "comment-parser";

export default {
globs: ["src/components/**/!(*.test|*.stories).ts"],
exclude: ["src/**/*.css", "src/components/icon/icon-list.ts"],
exclude: ["src/**/*.css", "src/**/*.constant.ts","src/**/*/*.types.ts","src/components/icon/icon-list.ts"],
outdir: "dist/",
dev: false,
watch: false,
Expand Down
2 changes: 1 addition & 1 deletion playground/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<script type="module" src="./dist/baklava.js"></script>
<script>
// Live reload
new EventSource('/esbuild').addEventListener('change', () => location.reload());
new EventSource("/esbuild").addEventListener("change", () => location.reload());
</script>
<style>
*:not(:defined) {
Expand Down
1 change: 1 addition & 0 deletions src/baklava.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ export { default as BlTableRow } from "./components/table/table-row/bl-table-row
export { default as BlTableHeaderCell } from "./components/table/table-header-cell/bl-table-header-cell";
export { default as BlTableCell } from "./components/table/table-cell/bl-table-cell";
export { default as BlSplitButton } from "./components/split-button/bl-split-button";
export { default as BlCalendar } from "./components/calendar/bl-calendar";
export { getIconPath, setIconPath } from "./utilities/asset-paths";
2 changes: 1 addition & 1 deletion src/components/button/bl-button.css
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
}

.button:focus-visible::after {
border: 2px solid var(--main-color);
border: 2px solid var(--bl-button-focus-border-color, var(--main-color));
border-radius: var(--bl-border-radius-l);
content: "";
position: absolute;
Expand Down
14 changes: 14 additions & 0 deletions src/components/calendar/bl-calendar.constant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export const FIRST_MONTH_INDEX = 0;
export const LAST_MONTH_INDEX = 11;

export enum CALENDAR_VIEWS {
DAYS = "days",
MONTHS = "months",
YEARS = "years",
}

export enum CALENDAR_TYPES {
dilandoogan marked this conversation as resolved.
Show resolved Hide resolved
SINGLE = "single",
MULTIPLE = "multiple",
RANGE = "range",
}
137 changes: 137 additions & 0 deletions src/components/calendar/bl-calendar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
.calendar {
display: flex;
flex-direction: column;
}

.calendar-content {
display: flex;
padding: 16px;
flex-direction: column;
align-items: center;
gap: 16px;
border-radius: var(--bl-border-radius-s);
width: fit-content;
border: 1px solid var(--bl-color-primary);
background: var(--bl-color-neutral-full);
}

.calendar-header {
display: flex;
justify-content: space-between;
width: 100%;
align-items: center;
gap: 2px;
}

.arrow {
flex: 1;
}

.header-text {
flex: 3;
}

.header-text-hover {
background: var(--bl-color-neutral-lightest);
border-radius: var(--bl-border-radius-s);
}

.days-wrapper {
display: flex;
flex-direction: column;
}

.day-wrapper {
display: flex;
align-items: center;
justify-content: center;
}

.week-row {
display: flex;
align-items: center;
flex-direction: row;
padding-bottom: 8px;
}

.day {
display: flex;
align-items: center;
width: 40px;

--bl-button-focus-border-color: #000;
--bl-font-title-4-medium: var(--bl-font-weight-regular) var(--bl-font-size-m);
--bl-size-xl: 40px;
--bl-border-radius-m: 50%;
--bl-border-radius-l: 50%;

&.today-day {
--bl-color-neutral-darker: var(--bl-color-primary);
--bl-color-neutral-darkest: var(--bl-color-primary);
}

&.selected-day {
background: var(--bl-color-primary);
border-radius: 50%;

--bl-button-focus-border-color: var(--bl-color-primary);
--bl-color-neutral-darker: var(--bl-color-neutral-full);
}

&.other-month-day {
--bl-color-neutral-darker: var(--bl-color-neutral-dark);
}
}

.range-day {
background: var(--bl-color-primary-contrast);

--bl-color-neutral-lightest: var(--bl-color-primary-contrast);
}

.range-end-day,
.range-start-day,
.selected-day {
--bl-color-neutral-lightest: var(--bl-color-primary);
--bl-color-neutral-darker: var(--bl-color-neutral-full);
--bl-color-neutral-darkest: var(--bl-color-neutral-full) !important;
}

.range-start-day {
background: var(--bl-color-primary-contrast);
border-top-left-radius: 50%;
border-bottom-left-radius: 50%;
}

.range-end-day {
background: var(--bl-color-primary-contrast);
border-top-right-radius: 50%;
border-bottom-right-radius: 50%;
}

.weekday-text {
color: var(--bl-color-neutral-dark);
text-align: center;
padding: 8px 0;
width: 40px;
}

.grid-content {
display: grid;
grid-template-columns: auto auto auto;
text-align: center;
}

.grid-item {
width: 93.33px;
ozkersemih marked this conversation as resolved.
Show resolved Hide resolved

--bl-size-3xs: 15px;
}

.grid-item:not(:nth-last-child(-n + 3)) {
padding-bottom: 8px;
}

.calendar-text {
font: var(--bl-font-title-3-regular);
}
93 changes: 93 additions & 0 deletions src/components/calendar/bl-calendar.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { html } from 'lit';
import { Meta, Canvas, ArgsTable, Story } from '@storybook/addon-docs';
import { ifDefined } from 'lit/directives/if-defined.js';
import { unsafeHTML } from 'lit/directives/unsafe-html.js';

<Meta
title="Components/Calendar"
component="bl-calendar"
argTypes={{
type: {
control: {
control: 'text',
description: 'Type of the calendar'
}
},
}}
/>

export const CalendarTemplate = (args) => html`<bl-calendar
type=${ifDefined(args.type)}
min-date=${ifDefined(args.minDate)}
max-date=${ifDefined(args.maxDate)}
start-of-week=${ifDefined(args.startOfWeek)}
locale=${ifDefined(args.locale)}
default-value=${ifDefined(args.defaultValue)}
disabled-dates=${ifDefined(args.disabledDates)}>${unsafeHTML(args.content)}</bl-calendar>`


export const Template = (args) => html`${CalendarTemplate({...args})}`;


# Calendar

<bl-badge icon="document">[ADR](https://github.com/Trendyol/baklava/issues/795)</bl-badge>
<bl-badge icon="puzzle">[Figma](https://www.figma.com/file/RrcLH0mWpIUy4vwuTlDeKN/Baklava-Design-Guide?type=design&node-id=1412-8914&mode=design&t=b0kU7tBfJQFvz2at-0)</bl-badge>

Calendar component is an **internal** component for using inside Datepicker component.

### Usage

* Calendar has three types such as **single**,**multiple** and **range**.Default calendar type is `single`.You can set calendar type by using `type` attribute.
* Calendar has **min-date** and **max-date** attributes.By entering these values,you can disable all dates before min-date property or will disable all dates after max-date property.
* Another attribute **disabled-dates** is also restrict the dates that can be selected on the calendar.
* Attribute **start-of-date** defines the days of the week, corresponding to 0 Sundays and 6 Saturdays. By entering this, you can choose from which day the calendar will create the calendar view.


## Calendar Types

### Single Type Calendar

Default calendar type is `single` and you can only select a single day from calendar.

<Canvas>
<Story name="Single Type Calendar" args={{ type: 'single' }}>
{Template.bind({})}
</Story>
</Canvas>

### Multiple Type Calendar

You can select multiple days from calendar.

<Canvas>
<Story name="Multiple Type Calendar" args={{ type: 'multiple' }}>
{Template.bind({})}
</Story>
</Canvas>


### Range Type Calendar

You can select date range from calendar.

<Canvas>
<Story name="Range Type Calendar" args={{ type: 'range' }}>
{Template.bind({})}
</Story>
</Canvas>

### Disabled Dates

You can set dates which you want to disable from calendar.

<Canvas>
<Story name="Disabled Dates" args={{ type: 'single',disabledDates:`["${new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate()+2)}"]` }}>
{Template.bind({})}
</Story>
</Canvas>


## Reference

<ArgsTable of="bl-calendar" />
Loading
Loading