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

Componente de calendário #214

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
5310f44
adding packages
HCarrer May 10, 2024
8e53509
component initial implementation
HCarrer May 10, 2024
701ad5c
minDate on end date calendar fix
HCarrer May 10, 2024
98095db
initial scss implementation
HCarrer May 15, 2024
587e8fe
selected date background
HCarrer May 16, 2024
87cd709
adding custom header
HCarrer May 21, 2024
ebfaa23
months calendar visual
HCarrer May 21, 2024
f5312e3
invalid days visual on hover fix
HCarrer May 22, 2024
e3f0be0
selecting range bg color fix
HCarrer May 22, 2024
bfd2c92
truncates minimum date
HCarrer May 22, 2024
8885a85
bug-fix: start date greater than end date
HCarrer May 23, 2024
2f54149
number of months as prop
HCarrer May 23, 2024
47f7bbf
text size
HCarrer May 23, 2024
fae55a3
showing date range on button
HCarrer May 23, 2024
924c78f
date format
HCarrer May 24, 2024
267023f
default periods as constants
HCarrer May 24, 2024
de69b14
default periods behaviour on date selection
HCarrer May 24, 2024
24a45e2
updating month on custom header
HCarrer May 24, 2024
1231897
adding position props
HCarrer May 24, 2024
241027b
position story
HCarrer May 24, 2024
bb50256
side files lint
HCarrer May 27, 2024
419d9bc
enables keyboard navigation
HCarrer May 27, 2024
7d574f9
same day different month name fix
HCarrer May 27, 2024
2ff81b5
closing months calendar on selection
HCarrer May 27, 2024
2e3fd2a
fixing wrong stories placement
HCarrer May 27, 2024
26a4a28
removing keyboard selected css
HCarrer May 27, 2024
3898909
adding rounded borders to start and end of selected period
HCarrer May 27, 2024
8463d02
animations on date change
HCarrer May 28, 2024
664f797
fomatting
HCarrer May 28, 2024
9483443
full file lint
HCarrer May 28, 2024
ea6a5f4
click outside not closing calendar
HCarrer May 29, 2024
406d796
npm remove and yarn add - datepicker
HCarrer May 29, 2024
680f36d
locale build error fix
HCarrer May 29, 2024
c3d287d
removing useless span tag
HCarrer May 31, 2024
8006554
lint fix
HCarrer May 31, 2024
a491c69
more lint
HCarrer May 31, 2024
e4ff3bd
initial test implementation
HCarrer May 31, 2024
f93f386
tests not running error fix
HCarrer May 31, 2024
71e27c1
initial default tests
HCarrer Jun 3, 2024
3456bfa
tests on desktop
HCarrer Jun 3, 2024
94c1196
prettier conditional hook fix
HCarrer Jun 3, 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 styleguide/cypress/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ import './commands'
import '@cypress/code-coverage/support'
import { setGlobalConfig } from "@storybook/testing-react"
import * as sbPreview from "../../.storybook/preview"
import 'babel-polyfill'

setGlobalConfig(sbPreview)
28,227 changes: 28,227 additions & 0 deletions styleguide/package-lock.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions styleguide/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,17 @@
"dependencies": {
"@loja-integrada/tailwindcss-config": "^1.7.6",
"@tippyjs/react": "^4.2.5",
"@types/react-datepicker": "^6.2.0",
"@types/react-select": "^4.0.17",
"babel-jest": "^29.2.2",
"babel-polyfill": "^6.26.0",
"child-process": "^1.0.2",
"dotenv": "^16.0.3",
"react": "^17.0.2",
"react-datepicker": "^6.9.0",
"react-dom": "^17.0.2",
"react-modal": "^3.14.3",
"react-responsive": "^10.0.0",
"react-select": "^4.3.1",
"react-table": "^7.7.0",
"react-text-mask": "^5.4.3",
Expand Down
57 changes: 57 additions & 0 deletions styleguide/src/Forms/Calendar/Calendar.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import * as React from 'react'
import { composeStories } from '@storybook/testing-react'
import { mount } from '@cypress/react'
import * as stories from './Calendar.stories'
import {
CUSTOM_PERIOD,
PREVIOUS_SEVEN_DAYS,
PREVIOUS_THIRTY_DAYS,
YESTERDAY,
} from './constants'
import { subDays } from 'date-fns'

const { Default } = composeStories(stories)

const today = new Date('2024-06-15')
const tenDaysAgo = subDays(today, 10)
const _tenDaysAgo = tenDaysAgo.getDate()
// const fiveDaysAgo = subDays(today, 5)
// const _fiveDaysAgo = fiveDaysAgo.getDate()

const specTitle = require('cypress-sonarqube-reporter/specTitle')
describe(specTitle('Calendar tests'), () => {
it('Default', () => {
mount(<Default today={today} testOnDesktop />)
// default periods click tests
cy.get(`#${YESTERDAY.id}`).within(() => {
cy.get('button')
.should('have.class', 'text-primary-dark')
.contains(YESTERDAY.label)
})
cy.get(`#${PREVIOUS_SEVEN_DAYS.id}`).within(() => {
cy.get('button')
.click()
.should('have.class', 'text-primary-dark')
.contains(PREVIOUS_SEVEN_DAYS.label)
})
cy.get(`#${PREVIOUS_THIRTY_DAYS.id}`).within(() => {
cy.get('button')
.click()
.should('have.class', 'text-primary-dark')
.contains(PREVIOUS_THIRTY_DAYS.label)
})
cy.get(`#${CUSTOM_PERIOD.id}`).within(() => {
cy.get('button')
.click()
.should('have.class', 'text-primary-dark')
.contains(CUSTOM_PERIOD.label)
})

// calendar days visual behaviour
// TODO: fix it!
cy.get('#startCalendar').within(() => {
cy.get(`.react-datepicker__day--00${_tenDaysAgo}`).click()
// cy.get(`.react-datepicker__day--00${_fiveDaysAgo}`).should('have.css', 'background-color', '#E4F3F3')
})
})
})
38 changes: 38 additions & 0 deletions styleguide/src/Forms/Calendar/Calendar.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react'
import { Story, Meta } from '@storybook/react'

import { Calendar, CalendarProps } from '.'
import { CUSTOM_PERIOD, YESTERDAY } from './constants'

export default {
title: 'Forms/Calendar',
component: Calendar,
parameters: {
layout: 'padded',
}
} as Meta

const Template: Story<CalendarProps> = args => <Calendar {...args} />

export const Default = Template.bind({})
Default.args = {
onDatesChange: function (startDate: Date, endDate: Date) {
return [startDate, endDate]
},
}

export const CustomPeriods = Template.bind({})
CustomPeriods.args = {
onDatesChange: function (startDate: Date, endDate: Date) {
return [startDate, endDate]
},
periods: [YESTERDAY, CUSTOM_PERIOD]
}

export const OnTheRight = Template.bind({})
OnTheRight.args = {
onDatesChange: function (startDate: Date, endDate: Date) {
return [startDate, endDate]
},
position: 'right'
}
50 changes: 50 additions & 0 deletions styleguide/src/Forms/Calendar/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { PeriodsType } from '.'

export const YESTERDAY: PeriodsType = {
id: 'ontem',
label: 'Ontem',
value: 1,
}

export const PREVIOUS_SEVEN_DAYS: PeriodsType = {
id: '7-dias',
label: '7 dias',
value: 7,
}

export const PREVIOUS_THIRTY_DAYS: PeriodsType = {
id: '30-dias',
label: '30 dias',
value: 30,
}

export const CUSTOM_PERIOD: PeriodsType = {
id: 'selecionar-periodo',
label: 'Selecionar período',
icon: 'calendarAlt',
}

export const defaultPeriods: PeriodsType[] = [
YESTERDAY,
PREVIOUS_SEVEN_DAYS,
PREVIOUS_THIRTY_DAYS,
CUSTOM_PERIOD,
]

export const months = [
'Janeiro',
'Fevereiro',
'Março',
'Abril',
'Maio',
'Junho',
'Julho',
'Agosto',
'Setembro',
'Outubro',
'Novembro',
'Dezembro',
]

export const WIDTH_TRANSITION_DURATION = 100
export const POSITION_TRANSITION_DURATION = 200
Loading
Loading