calendar-events 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +58 -15
  2. package/bin/init.js +25 -51
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # calendar-events
2
2
 
3
- A lightweight, customizable React calendar component with event support. Built with TypeScript and Tailwind CSS, featuring generic typed events, render props for full control over event display, a loading state with an animated SVG icon, and seamless dark mode via CSS variables (shadcn/ui compatible).
3
+ A lightweight, customizable React calendar component with event support. Built with TypeScript and native CSS, featuring generic typed events, render props for full control over event display, a loading state with an animated SVG icon, and seamless dark mode via CSS variables.
4
4
 
5
5
  ## Features
6
6
 
@@ -8,13 +8,15 @@ A lightweight, customizable React calendar component with event support. Built w
8
8
  - **Render props** — fully control how each event is rendered inside a day cell
9
9
  - **Loading state** — built-in animated calendar icon overlay while fetching data
10
10
  - **Dark mode** — works out of the box with a `.dark` class using CSS custom properties
11
- - **shadcn/ui compatible** — uses the same CSS variable conventions, so it slots into any shadcn/ui project with no extra configuration
11
+ - **No framework dependencies** — uses native CSS with `--ce-*` prefixed variables, compatible with any design system
12
12
  - **Modular** — all sub-components are exported individually so you can compose your own layout
13
13
 
14
14
  ## Installation
15
15
 
16
16
  ```bash
17
17
  npm install calendar-events
18
+ # or
19
+ pnpm add calendar-events
18
20
  ```
19
21
 
20
22
  **Peer dependencies** (install if not already present):
@@ -23,6 +25,31 @@ npm install calendar-events
23
25
  npm install react react-dom
24
26
  ```
25
27
 
28
+ ## Color palette setup
29
+
30
+ After installing, run the following command to choose a color palette for your project:
31
+
32
+ ```bash
33
+ npm exec calendar-events
34
+ # or
35
+ pnpm exec calendar-events
36
+ ```
37
+
38
+ This interactive CLI will ask you to pick a **color** and a **shade**, then automatically write the selected values into the `dist/style.css` file.
39
+
40
+ **Available colors:**
41
+
42
+ | # | Color | Description |
43
+ |---|-------|-------------|
44
+ | 1 | `verde` | Green |
45
+ | 2 | `rojo` | Red |
46
+ | 3 | `amarillo` | Yellow |
47
+ | 4 | `morado` | Purple |
48
+ | 5 | `azul` | Blue |
49
+ | 6 | `naranja` | Orange |
50
+
51
+ **Available shades:** `claro` (light) · `medio` (medium) · `oscuro` (dark)
52
+
26
53
  ## Usage
27
54
 
28
55
  ### 1. Import the styles
@@ -33,8 +60,6 @@ Import the CSS once at the root of your app (e.g. `main.tsx` or `layout.tsx`):
33
60
  import 'calendar-events/style.css'
34
61
  ```
35
62
 
36
- > **Already using shadcn/ui?** Skip this import — your existing CSS variables are already compatible.
37
-
38
63
  ### 2. Use the component
39
64
 
40
65
  ```tsx
@@ -112,8 +137,15 @@ Use the `renderEvent` prop to replace the default event pill with anything you w
112
137
  events={events}
113
138
  renderEvent={(event) => (
114
139
  <span
115
- className="block rounded px-2 py-0.5 text-xs text-white truncate"
116
- style={{ backgroundColor: event.data?.color }}
140
+ style={{
141
+ display: 'block',
142
+ borderRadius: '4px',
143
+ padding: '2px 8px',
144
+ fontSize: '0.75rem',
145
+ color: 'white',
146
+ overflow: 'hidden',
147
+ backgroundColor: event.data?.color,
148
+ }}
117
149
  >
118
150
  {event.title}
119
151
  </span>
@@ -163,18 +195,29 @@ The library styles are built on CSS custom properties. If you imported `calendar
163
195
 
164
196
  ```css
165
197
  :root {
166
- --primary: 222.2 47.4% 11.2%;
167
- --primary-foreground: 210 40% 98%;
168
- --secondary: 210 40% 96.1%;
169
- --muted-foreground: 215.4 16.3% 46.9%;
170
- --accent: 210 40% 96.1%;
171
- --border: 214.3 31.8% 91.4%;
172
- --background: 0 0% 100%;
173
- --radius: 0.5rem;
198
+ --ce-background: 0 0% 100%;
199
+ --ce-foreground: 222.2 84% 4.9%;
200
+ --ce-primary: 222.2 47.4% 11.2%;
201
+ --ce-primary-foreground: 210 40% 98%;
202
+ --ce-secondary: 210 40% 96.1%;
203
+ --ce-muted-foreground: 215.4 16.3% 46.9%;
204
+ --ce-accent: 210 40% 96.1%;
205
+ --ce-border: 214.3 31.8% 91.4%;
206
+ --ce-radius: 0.5rem;
174
207
  }
175
208
  ```
176
209
 
177
- Values follow the `H S% L%` HSL format (no `hsl()` wrapper) so Tailwind's opacity modifier syntax works correctly.
210
+ Values follow the `H S% L%` HSL format (no `hsl()` wrapper).
211
+
212
+ If you use shadcn/ui, you can map your existing variables:
213
+
214
+ ```css
215
+ :root {
216
+ --ce-primary: var(--primary);
217
+ --ce-border: var(--border);
218
+ /* etc. */
219
+ }
220
+ ```
178
221
 
179
222
  ## Dark mode
180
223
 
package/bin/init.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { createInterface } from 'readline'
4
- import { readFileSync, writeFileSync, existsSync, createReadStream, createWriteStream } from 'fs'
3
+ import { intro, outro, select, spinner, isCancel, cancel } from '@clack/prompts'
4
+ import { readFileSync, writeFileSync } from 'fs'
5
5
  import { join, dirname } from 'path'
6
6
  import { fileURLToPath } from 'url'
7
7
 
@@ -35,7 +35,7 @@ const PALETTES = {
35
35
  },
36
36
  naranja: {
37
37
  claro: { primary: '24 90% 63%', secondary: '24 55% 93%', accent: '24 55% 94%', 'muted-foreground': '24 20% 55%', border: '24 35% 84%' },
38
- medio: { primary: '24 100% 50%', secondary: '24 45% 90%', accent: '24 45% 91%', 'muted-foreground': '24 15% 50%', border: '24 25% 80%' },
38
+ medio: { primary: '24 100% 50%', secondary: '24 45% 90%', accent: '24 45% 91%', 'muted-foreground': '24 15% 50%', border: '24 15% 76%' },
39
39
  oscuro: { primary: '24 100% 36%', secondary: '24 30% 87%', accent: '24 30% 88%', 'muted-foreground': '24 10% 45%', border: '24 15% 76%' },
40
40
  },
41
41
  }
@@ -43,62 +43,35 @@ const PALETTES = {
43
43
  const COLOR_OPTIONS = ['verde', 'rojo', 'amarillo', 'morado', 'azul', 'naranja']
44
44
  const SHADE_OPTIONS = ['claro', 'medio', 'oscuro']
45
45
 
46
- function openTTY() {
47
- // When npm/pnpm pipes stdin, we open /dev/tty directly to get
48
- // an interactive terminal regardless of how the script was spawned.
49
- if (process.stdin.isTTY) {
50
- return { input: process.stdin, output: process.stdout }
51
- }
52
- if (!existsSync('/dev/tty')) return null
53
- try {
54
- return {
55
- input: createReadStream('/dev/tty'),
56
- output: createWriteStream('/dev/tty'),
57
- }
58
- } catch {
59
- return null
60
- }
61
- }
62
-
63
- function ask(rl, prompt) {
64
- return new Promise(resolve => rl.question(prompt, resolve))
65
- }
66
-
67
46
  async function main() {
68
- const tty = openTTY()
69
- if (!tty) process.exit(0) // CI/CD — skip setup silently
47
+ // Salir silenciosamente en CI/CD (sin TTY)
48
+ if (!process.stdout.isTTY) process.exit(0)
70
49
 
71
- const rl = createInterface(tty)
50
+ intro('calendar-events Setup de color')
72
51
 
73
- tty.output.write('\ncalendar-events setup\n\n')
52
+ const colorKey = await select({
53
+ message: 'Selecciona una paleta de colores:',
54
+ options: COLOR_OPTIONS.map(c => ({ value: c, label: c })),
55
+ })
74
56
 
75
- tty.output.write('Selecciona una paleta de colores:\n')
76
- COLOR_OPTIONS.forEach((color, i) => tty.output.write(` ${i + 1}. ${color}\n`))
77
-
78
- const colorAnswer = (await ask(rl, '\nColor (1-6): ')).trim()
79
- const colorKey = COLOR_OPTIONS[parseInt(colorAnswer) - 1]
80
-
81
- if (!colorKey) {
82
- tty.output.write('Seleccion invalida.\n')
83
- rl.close()
84
- process.exit(1)
57
+ if (isCancel(colorKey)) {
58
+ cancel('Setup cancelado.')
59
+ process.exit(0)
85
60
  }
86
61
 
87
- tty.output.write(`\nSelecciona un tono para ${colorKey}:\n`)
88
- tty.output.write(' 1. Claro\n')
89
- tty.output.write(' 2. Medio\n')
90
- tty.output.write(' 3. Oscuro\n')
91
-
92
- const shadeAnswer = (await ask(rl, '\nTono (1-3): ')).trim()
93
- const shadeKey = SHADE_OPTIONS[parseInt(shadeAnswer) - 1]
62
+ const shadeKey = await select({
63
+ message: `Selecciona un tono para ${colorKey.toLocaleUpperCase()}:`,
64
+ options: SHADE_OPTIONS.map(s => ({ value: s, label: s })),
65
+ })
94
66
 
95
- rl.close()
96
-
97
- if (!shadeKey) {
98
- tty.output.write('Seleccion invalida.\n')
99
- process.exit(1)
67
+ if (isCancel(shadeKey)) {
68
+ cancel('Setup cancelado.')
69
+ process.exit(0)
100
70
  }
101
71
 
72
+ const s = spinner()
73
+ s.start('Aplicando paleta...')
74
+
102
75
  const palette = PALETTES[colorKey][shadeKey]
103
76
  const cssPath = join(__dirname, '..', 'dist', 'style.css')
104
77
  let css = readFileSync(cssPath, 'utf-8')
@@ -112,7 +85,8 @@ async function main() {
112
85
 
113
86
  writeFileSync(cssPath, css)
114
87
 
115
- tty.output.write(`\nPaleta aplicada: ${colorKey} ${shadeKey}\n`)
88
+ s.stop('Paleta aplicada.')
89
+ outro(`${colorKey} ${shadeKey} — listo!`)
116
90
  }
117
91
 
118
92
  main()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "calendar-events",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "A customizable React calendar component with event support",
5
5
  "type": "module",
6
6
  "main": "./dist/calendar-events.cjs",
@@ -38,8 +38,7 @@
38
38
  "react",
39
39
  "calendar",
40
40
  "events",
41
- "component",
42
- "tailwindcss"
41
+ "component"
43
42
  ],
44
43
  "author": "",
45
44
  "license": "MIT",
@@ -48,6 +47,7 @@
48
47
  "react-dom": "^18.0.0 || ^19.0.0"
49
48
  },
50
49
  "dependencies": {
50
+ "@clack/prompts": "^1.0.1",
51
51
  "clsx": "^2.1.1",
52
52
  "lucide-react": "^0.468.0",
53
53
  "tailwind-merge": "^2.5.4"