WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 27ce65b

Browse files
committed
feat: add WCAG accessibility
1 parent 39ac08f commit 27ce65b

File tree

25 files changed

+2655
-1285
lines changed

25 files changed

+2655
-1285
lines changed

.github/workflows/publish.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ on:
66
- "v*.*.*"
77
workflow_dispatch:
88

9-
permissions:
10-
contents: write
11-
id-token: write
12-
139
jobs:
1410
publish:
1511
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
id-token: write
1615
steps:
1716
- name: Checkout
1817
uses: actions/checkout@v4
@@ -44,6 +43,6 @@ jobs:
4443
run: pnpm run build
4544

4645
- name: Publish to npm
47-
run: pnpm publish --access public --provenance --no-git-checks
46+
run: npm publish --access public --provenance --no-git-checks
4847
env:
4948
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.storybook/manager.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { addons } from "storybook/manager-api";
2+
import theme from "./theme";
3+
4+
addons.setConfig({
5+
theme,
6+
});

.storybook/theme.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { create } from "storybook/theming/create";
2+
3+
export default create({
4+
base: "light",
5+
6+
// Typography - Modern, readable fonts
7+
fontBase: '"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
8+
fontCode: '"JetBrains Mono", "Fira Code", Consolas, "Liberation Mono", Menlo, monospace',
9+
10+
// Branding - Inspired by the vibrant logo gradient
11+
brandTitle: "Color Calendar",
12+
brandUrl: "https://master--68dc1b2449e62022d61d079f.chromatic.com/",
13+
brandImage: "./screenshots/logo.png", // Use the colorful gradient logo
14+
brandTarget: "_self",
15+
16+
// Color palette - Inspired by logo gradient and calendar themes
17+
colorPrimary: "#8b5cf6", // Purple-500 - From logo gradient
18+
colorSecondary: "#f59e0b", // Amber-500 - From logo gradient
19+
20+
// UI - Clean backgrounds inspired by calendar designs
21+
appBg: "#fefefe", // Pure white background like calendar cards
22+
appContentBg: "#ffffff", // Clean white content areas
23+
appPreviewBg: "#ffffff", // Clean preview background
24+
appBorderColor: "#e5e7eb", // Subtle border like calendar separators
25+
appBorderRadius: 12, // Rounded corners like calendar cards
26+
27+
// Text colors - High contrast for readability
28+
textColor: "#111827", // Dark gray like calendar text
29+
textInverseColor: "#ffffff", // Pure white for inverse text
30+
31+
// Toolbar - Clean design inspired by calendar headers
32+
barTextColor: "#6b7280", // Muted gray text
33+
barSelectedColor: "#8b5cf6", // Purple primary from logo
34+
barHoverColor: "#f59e0b", // Amber secondary from logo
35+
barBg: "#ffffff", // Clean white background
36+
37+
// Form elements - Modern design matching calendar aesthetics
38+
inputBg: "#ffffff", // Clean white background
39+
inputBorder: "#d1d5db", // Subtle border
40+
inputTextColor: "#111827", // Dark text for readability
41+
inputBorderRadius: 8, // Rounded corners matching calendar style
42+
});

README.md

Lines changed: 82 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,42 @@
5252

5353
## 🚀 Features
5454

55-
- Zero dependencies
56-
- Add events to calendar with **individual event colors**
57-
- **Configurable event bullet modes** - show multiple bullets or single bullet
58-
- Perform some action on calendar date change
59-
- Month and year picker built-in
60-
- Themes available
61-
- Fully customizable using CSS variables, passing options parameters while creating calendar, or overriding CSS.
55+
- 🏎️ **Zero Dependencies**: Lightweight and fast
56+
- 🎉 **Event Support**: Add events to calendar with individual event colors
57+
- 🔵 **Configurable Event Bullet Modes**: Show multiple bullets or single bullet per day
58+
- 📅 **Month and Year Picker**: Built-in navigation controls
59+
- 🎨 **Multiple Themes**: Choose from various color schemes and design styles
60+
- 🛠️ **Fully Customizable**: Using CSS variables, options parameters, or CSS overrides
61+
- 📱 **Responsive Design**: Works seamlessly across desktop and mobile devices
62+
-**Accessibility**: Built with WCAG guidelines in mind
6263
- [Request more features](#feature-request)...
6364

6465
<a id="getting-started"></a>
6566

6667
## 📦 Getting Started
6768

69+
### NPM
70+
71+
> _You might need to use a module bundler such as webpack, rollup, parcel, etc._
72+
73+
#### Installation
74+
75+
```bash
76+
npm i color-calendar
77+
```
78+
79+
#### Import
80+
81+
```javascript
82+
import Calendar from "color-calendar";
83+
```
84+
85+
#### CSS
86+
87+
```javascript
88+
import "color-calendar/dist/css/theme-<THEME-NAME>.css";
89+
```
90+
6891
### CDN
6992

7093
#### JavaScript
@@ -104,30 +127,6 @@ Get fonts from [Google Fonts](https://fonts.google.com/)
104127
105128
Check what fonts the [theme](#themes) needs or pass your own fonts in [options](#options-fonts).
106129
107-
### NPM
108-
109-
> _You might need to use a module bundler such as webpack, rollup, parcel, etc._
110-
111-
#### Installation
112-
113-
```bash
114-
npm i color-calendar
115-
```
116-
117-
#### Import
118-
119-
```javascript
120-
import Calendar from "color-calendar";
121-
```
122-
123-
#### CSS
124-
125-
```javascript
126-
import "color-calendar/dist/css/theme-<THEME-NAME>.css";
127-
```
128-
129-
Then add fonts.
130-
131130
<a id="usage"></a>
132131
133132
## 🔨 Usage
@@ -146,8 +145,9 @@ _Or_ you can pass in **options**.
146145
147146
```javascript
148147
new Calendar({
149-
id: "#color-calendar",
150-
calendarSize: "small"
148+
container: "#color-calendar",
149+
calendarSize: "small",
150+
initialSelectedDate: new Date(2024, 5, 15) // June 15, 2024
151151
});
152152
```
153153
@@ -164,31 +164,30 @@ new Calendar({
164164
```javascript
165165
// Using a function that returns an HTMLElement
166166
new Calendar({
167-
id: () => document.getElementById("my-calendar"),
168-
calendarSize: "large"
167+
container: () => document.getElementById("my-calendar")
169168
});
170169
171170
// Dynamic element creation
172171
new Calendar({
173-
id: () => {
174-
let container = document.getElementById("calendar-container");
175-
if (!container) {
176-
container = document.createElement("div");
177-
container.id = "calendar-container";
178-
container.style.padding = "20px";
179-
document.body.appendChild(container);
180-
}
172+
container: () => {
173+
const container = document.createElement("div");
174+
document.body.appendChild(container);
181175
return container;
182-
},
183-
calendarSize: "large"
176+
}
177+
});
178+
179+
// Using HTMLElement directly
180+
const myElement = document.getElementById("my-calendar");
181+
new Calendar({
182+
container: myElement
184183
});
185184
```
186185
187186
#### Event Colors and Bullet Modes
188187
189188
```javascript
190189
new Calendar({
191-
id: "#calendar",
190+
container: "#calendar",
192191
eventBulletMode: "multiple", // or "single"
193192
eventsData: [
194193
{
@@ -216,7 +215,6 @@ new Calendar({
216215
**Key Features:**
217216
- **Individual Event Colors**: Each event can have its own color
218217
- **Cross-Month Support**: Events spanning multiple months display correctly
219-
- **White Bullets on Selection**: Selected dates show white bullets for better contrast
220218
- **Configurable Bullet Modes**: Choose between multiple bullets or single bullet per day
221219
222220
<a id="usage-react"></a>
@@ -235,26 +233,28 @@ new Calendar({
235233
236234
## ⚙️ Options
237235
238-
### `id`
236+
### `container`
239237
240-
Type: `String | Function`
238+
Type: `String | HTMLElement | Function`
241239
Default: `#color-calendar`
242240
243241
Selector referencing HTMLElement where the calendar instance will bind to.
244242
245243
**String**: CSS selector string (e.g., `"#my-calendar"`, `".calendar-container"`)
246244
245+
**HTMLElement**: Direct reference to an HTMLElement
246+
247247
**Function**: Function that returns an HTMLElement or null
248248
```javascript
249-
// Function-based id example
249+
// Function-based container example
250250
const calendar = new ColorCalendar({
251-
id: () => document.getElementById("my-calendar"),
251+
container: () => document.getElementById("my-calendar"),
252252
// ... other options
253253
});
254254
255255
// Dynamic element creation
256256
const calendar = new ColorCalendar({
257-
id: () => {
257+
container: () => {
258258
let container = document.getElementById("calendar-container");
259259
if (!container) {
260260
container = document.createElement("div");
@@ -265,6 +265,27 @@ const calendar = new ColorCalendar({
265265
},
266266
// ... other options
267267
});
268+
269+
// Using HTMLElement directly
270+
const myElement = document.getElementById("my-calendar");
271+
const calendar = new ColorCalendar({
272+
container: myElement,
273+
// ... other options
274+
});
275+
```
276+
277+
### `initialSelectedDate`
278+
279+
Type: `Date`
280+
Default: `undefined` (uses current date)
281+
282+
Sets the initial selected date when the calendar is first rendered. The calendar will open with this date selected and the view will be set to the month containing this date.
283+
284+
```javascript
285+
new Calendar({
286+
container: "#calendar",
287+
initialSelectedDate: new Date(2024, 5, 15) // June 15, 2024
288+
});
268289
```
269290
270291
### `calendarSize`
@@ -293,7 +314,8 @@ Default: `[]`
293314
{
294315
start: '2020-08-17T06:00:00',
295316
end: '2020-08-18T20:30:00',
296-
name: 'Blockchain 101'
317+
name: 'Blockchain 101',
318+
color: '#ff0000'
297319
...
298320
},
299321
...
@@ -465,7 +487,7 @@ Controls how event bullets are displayed when multiple events exist on the same
465487
466488
```javascript
467489
new Calendar({
468-
id: "#calendar",
490+
container: "#calendar",
469491
eventBulletMode: "single", // or "multiple"
470492
eventsData: [
471493
{
@@ -488,7 +510,7 @@ new Calendar({
488510
489511
## 🖱 Events
490512
491-
### `dateChanged`
513+
### `onSelectedDateChange`
492514
493515
Type: `Function`
494516
Props:
@@ -503,7 +525,7 @@ Props:
503525
```typescript
504526
const options = {
505527
...
506-
dateChanged: (currentDate?: Date, filteredDateEvents?: EventData[]) => {
528+
onSelectedDateChange: (currentDate?: Date, filteredDateEvents?: EventData[]) => {
507529
// do something
508530
};
509531
...
@@ -512,7 +534,7 @@ const options = {
512534
513535
Emitted when the selected date is changed.
514536
515-
### `selectedDateClicked`
537+
### `onSelectedDateClick`
516538
517539
Type: `Function`
518540
Props:
@@ -526,7 +548,7 @@ Props:
526548
527549
Emitted when the selected date is clicked.
528550
529-
### `monthChanged`
551+
### `onMonthChange`
530552
531553
Type: `Function`
532554
Props:
@@ -554,7 +576,7 @@ let myCal = new Calendar();
554576
myCal.reset();
555577
```
556578
557-
### `setDate()`
579+
### `setSelectedDate()`
558580
559581
Props:
560582
| Props | Type | Required | Description |
@@ -565,7 +587,7 @@ Set new selected date.
565587
566588
```javascript
567589
// Example
568-
myCal.setDate(new Date());
590+
myCal.setSelectedDate(new Date());
569591
```
570592
571593
### `getSelectedDate()`

biome.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
},
88
"files": {
99
"ignoreUnknown": false,
10-
"includes": ["src/**/*", "*.ts", "*.js", "*.json", "*.css"],
10+
"includes": ["src/**/*", "*.ts", "*.js", "*.json", "*.css", "**/*.ts"],
1111
"experimentalScannerIgnores": [
1212
"node_modules/**",
1313
"dist/**",
1414
"build/**",
1515
"coverage/**",
1616
"*.min.js",
1717
"*.bundle.js",
18-
"pnpm-lock.yaml"
18+
"pnpm-lock.yaml",
19+
".github/**"
1920
]
2021
},
2122
"formatter": {

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
"@rollup/plugin-strip": "^3.0.4",
4444
"@rollup/plugin-terser": "^0.4.4",
4545
"@rollup/plugin-typescript": "^12.1.4",
46-
"@storybook/addon-docs": "9.1.9",
47-
"@storybook/html-vite": "9.1.9",
46+
"@storybook/addon-docs": "9.1.10",
47+
"@storybook/html-vite": "9.1.10",
4848
"@tsconfig/recommended": "^1.0.10",
4949
"autoprefixer": "^10.4.21",
5050
"chromatic": "^13.3.0",
@@ -61,7 +61,7 @@
6161
"rollup": "^4.52.3",
6262
"rollup-plugin-banner2": "^1.3.1",
6363
"sass": "^1.93.2",
64-
"storybook": "9.1.9",
64+
"storybook": "9.1.10",
6565
"typescript": "^5.9.2",
6666
"vitest": "^2.1.9"
6767
},

0 commit comments

Comments
 (0)