-
Notifications
You must be signed in to change notification settings - Fork 235
feat(calendar): add calendar component #3327
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
Merged
+1,816
−0
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
3ca0ba5
feat: add calendar
paulodetarsofm f8e27de
feat: use first day of the week according to the locale
paulodetarsofm 304e0c9
feat: add "disabled" property
paulodetarsofm fdd0660
feat: handle "Previous" and "Next" month buttons
paulodetarsofm 07fdf78
feat: add locale for all stories
paulodetarsofm b61eea7
feat: add "min" and "max" date
paulodetarsofm 619be78
refactor: add new render methods
paulodetarsofm 6336db2
feat: format day using Intl.NumberFormat
paulodetarsofm 2ac6dd3
fix: lit-plugin "no-incompatible-property-type"
paulodetarsofm d218c5e
fix: packages version + property type error
paulodetarsofm db4d3fb
refactor: add to-do list to README
paulodetarsofm bbe6171
feat: add event handlers and slots for icons
paulodetarsofm c18991c
refactor(calendar): update dependencies
paulodetarsofm f9f05ca
refactor(calendar): changing Lit resource import source
paulodetarsofm a4e15e4
refactor: add comments and use correct formatters
paulodetarsofm 1e8b319
refactor: convert property `_locale` to a getter
paulodetarsofm 004029d
refactor: remove `_` from private properties and methods
paulodetarsofm 3208d99
refactor: remove unnecessary method
paulodetarsofm 19d288c
refactor: remove unnecessary template checking
paulodetarsofm fbd2d29
refactor: add new private properties
paulodetarsofm b18c3f1
refactor: code improvements, new comments
paulodetarsofm 185f79f
refactor: remove reflect from properties they don't need
paulodetarsofm dec3be5
fix: add new package to tsconfig.json
paulodetarsofm d4f08ef
refactor: use same version of `@internationalized/number` used by oth…
paulodetarsofm c235d4f
refactor(calendar): improvements and new TODOs
paulodetarsofm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| stories | ||
| test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| ## Description | ||
|
|
||
| ### Usage | ||
|
|
||
| [](https://www.npmjs.com/package/@spectrum-web-components/calendar) | ||
| [](https://bundlephobia.com/result?p=@spectrum-web-components/calendar) | ||
|
|
||
| ``` | ||
| yarn add @spectrum-web-components/calendar | ||
| ``` | ||
|
|
||
| Import the side effectful registration of `<sp-calendar>` via: | ||
|
|
||
| ``` | ||
| import '@spectrum-web-components/calendar/sp-calendar.js'; | ||
| ``` | ||
|
|
||
| When looking to leverage the `Calendar` base class as a type and/or for extension purposes, do so via: | ||
|
|
||
| ``` | ||
| import { Calendar } from '@spectrum-web-components/calendar'; | ||
| ``` | ||
|
|
||
| ## Example | ||
|
|
||
| ```html | ||
| <sp-calendar></sp-calendar> | ||
| ``` | ||
|
|
||
| ## To-do list | ||
|
|
||
| - Implement a cache mechanism to store the value of `today` and use this value to initialise `currentDate` | ||
| - Include a condition to run the `setWeekdays()` method only when really needed | ||
| - Attribute 'role="heading"' removed, due to error 'The "heading" role requires the attribute "aria-level"' | ||
| - Translate the "Previous" text used in the "title" and "aria-label" of the button displayed in the header of the calendar | ||
| - Translate the "Next" text used in the "title" and "aria-label" of the button displayed in the header of the calendar | ||
| - The title must include "Today," and " selected" translated to the current language | ||
| - Implement keyboard navigation | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We just walked through the Focus Group and Roving Tab Index Reactive Controllers as a team today. This might be a good place to prove out the knowledge of those APIs @jnjosh. |
||
| - Add support for other types of calendars - [React Calendar: International Calendars](https://react-spectrum.adobe.com/react-spectrum/Calendar.html#international-calendars) | ||
| - Include `aria-label` in calendar for accessibility - [React Calendar: Labeling](https://react-spectrum.adobe.com/react-spectrum/Calendar.html#labeling) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "./src/*": "./src/*.js", | ||
| "./sp-calendar.js": "./sp-calendar.js" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| { | ||
| "name": "@spectrum-web-components/calendar", | ||
| "version": "0.0.1", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "description": "Web component implementation of a Spectrum Calendar", | ||
| "license": "Apache-2.0", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/adobe/spectrum-web-components.git", | ||
| "directory": "packages/calendar" | ||
| }, | ||
| "author": "", | ||
| "homepage": "https://adobe.github.io/spectrum-web-components/components/calendar", | ||
| "bugs": { | ||
| "url": "https://github.com/adobe/spectrum-web-components/issues" | ||
| }, | ||
| "main": "./src/index.js", | ||
| "module": "./src/index.js", | ||
| "type": "module", | ||
| "exports": { | ||
| ".": { | ||
| "development": "./src/index.dev.js", | ||
| "default": "./src/index.js" | ||
| }, | ||
| "./package.json": "./package.json", | ||
| "./src/Calendar.js": { | ||
| "development": "./src/Calendar.dev.js", | ||
| "default": "./src/Calendar.js" | ||
| }, | ||
| "./src/calendar.css.js": "./src/calendar.css.js", | ||
| "./src/index.js": { | ||
| "development": "./src/index.dev.js", | ||
| "default": "./src/index.js" | ||
| }, | ||
| "./src/types.js": { | ||
| "development": "./src/types.dev.js", | ||
| "default": "./src/types.js" | ||
| }, | ||
| "./sp-calendar.js": { | ||
| "development": "./sp-calendar.dev.js", | ||
| "default": "./sp-calendar.js" | ||
| } | ||
| }, | ||
| "scripts": { | ||
| "test": "echo \"Error: run tests from mono-repo root.\" && exit 1" | ||
| }, | ||
| "files": [ | ||
| "**/*.d.ts", | ||
| "**/*.js", | ||
| "**/*.js.map", | ||
| "custom-elements.json", | ||
| "!stories/", | ||
| "!test/" | ||
| ], | ||
| "keywords": [ | ||
| "spectrum css", | ||
| "web components", | ||
| "lit-element", | ||
| "lit-html" | ||
| ], | ||
| "dependencies": { | ||
| "@internationalized/date": "^3.2.0", | ||
| "@internationalized/number": "^3.1.0", | ||
| "@spectrum-web-components/action-button": "^0.34.0", | ||
| "@spectrum-web-components/base": "^0.34.0", | ||
| "@spectrum-web-components/icons-workflow": "^0.34.0", | ||
| "@spectrum-web-components/reactive-controllers": "^0.34.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@spectrum-css/calendar": "^3.2.6" | ||
| }, | ||
| "types": "./src/index.d.ts", | ||
| "customElements": "custom-elements.json", | ||
| "sideEffects": [ | ||
| "./sp-*.js", | ||
| "./**/*.dev.js" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /* | ||
| Copyright 2023 Adobe. All rights reserved. | ||
| This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. You may obtain a copy | ||
| of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software distributed under | ||
| the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
| OF ANY KIND, either express or implied. See the License for the specific language | ||
| governing permissions and limitations under the License. | ||
| */ | ||
| import { Calendar } from './src/Calendar.js'; | ||
|
|
||
| customElements.define('sp-calendar', Calendar); | ||
|
|
||
| declare global { | ||
| interface HTMLElementTagNameMap { | ||
| 'sp-calendar': Calendar; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add more robust docs later...but know it'll be required at some point before a full release.