@gfazioli/mantine-clock 1.0.0

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.
@@ -0,0 +1,128 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity
10
+ and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ - Demonstrating empathy and kindness toward other people
21
+ - Being respectful of differing opinions, viewpoints, and experiences
22
+ - Giving and gracefully accepting constructive feedback
23
+ - Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ - Focusing on what is best not just for us as individuals, but for the
26
+ overall community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ - The use of sexualized language or imagery, and sexual attention or
31
+ advances of any kind
32
+ - Trolling, insulting or derogatory comments, and personal or political attacks
33
+ - Public or private harassment
34
+ - Publishing others' private information, such as a physical or email
35
+ address, without their explicit permission
36
+ - Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ ionut.florescu@gmail.com.
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series
86
+ of actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or
93
+ permanent ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within
113
+ the community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.0, available at
119
+ https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120
+
121
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct
122
+ enforcement ladder](https://github.com/mozilla/diversity).
123
+
124
+ [homepage]: https://www.contributor-covenant.org
125
+
126
+ For answers to common questions about this code of conduct, see the FAQ at
127
+ https://www.contributor-covenant.org/faq. Translations are available at
128
+ https://www.contributor-covenant.org/translations.
@@ -0,0 +1,18 @@
1
+ # Contributing
2
+
3
+ 👏 Thank you for considering contributing to this project.
4
+
5
+ ## Bug Reports
6
+
7
+ When encountering issues with software or applications, submitting a detailed bug report can significantly help developers in understanding and resolving the problem efficiently. A well-written bug report should include clear steps to reproduce the issue, the expected behavior, and the actual outcome.
8
+
9
+ Furthermore, providing information such as system specifications, error messages, and screenshots can aid in pinpointing the root cause of the bug. By utilizing platforms like GitHub, users can create issue tickets with relevant details, facilitating effective communication between users and developers. Remember, a comprehensive bug report not only assists in bug resolution but also improves the overall quality of the software.
10
+
11
+ 🐛 [GitHub issue](https://github.com/gfazioli/mantine-clock/issues)
12
+
13
+
14
+ ## Code contributors
15
+
16
+ Here's a list of all the people who have contributed to the codebase of this project so far:
17
+
18
+ [![Contributors list](https://contrib.rocks/image?repo=gfazioli/mantine-clock)](https://github.com/gfazioli/mantine-clock/graphs/contributors)
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Giovambattista Fazioli
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,228 @@
1
+ # Mantine Clock Component
2
+
3
+ https://github.com/user-attachments/assets/727a8634-28ee-4279-80b1-dcf2cb7f5961
4
+
5
+ ---
6
+
7
+ <div align="center">
8
+
9
+ [![NPM version](https://img.shields.io/npm/v/%40gfazioli%2Fmantine-clock?style=for-the-badge)](https://www.npmjs.com/package/@gfazioli/mantine-clock)
10
+ [![NPM Downloads](https://img.shields.io/npm/dm/%40gfazioli%2Fmantine-clock?style=for-the-badge)](https://www.npmjs.com/package/@gfazioli/mantine-clock)
11
+ [![NPM Downloads](https://img.shields.io/npm/dy/%40gfazioli%2Fmantine-clock?style=for-the-badge&label=%20&color=f90)](https://www.npmjs.com/package/@gfazioli/mantine-clock)
12
+ ![NPM License](https://img.shields.io/npm/l/%40gfazioli%2Fmantine-clock?style=for-the-badge)
13
+
14
+ </div>
15
+
16
+ ## Overview
17
+
18
+ This component is created on top of the [Mantine](https://mantine.dev/) library.
19
+
20
+ [![Mantine UI Library](https://img.shields.io/badge/-MANTINE_UI_LIBRARY-blue?style=for-the-badge&labelColor=black&logo=mantine
21
+ )](https://mantine.dev/)
22
+
23
+ It provides the capability to generate a dynamic clock effect, enabling the display of a wide variety of content in a visually engaging manner. This effect can enhance the overall user experience by drawing attention to important information, announcements, or promotions, allowing for a more interactive and captivating presentation.
24
+
25
+ [![Mantine Extensions](https://img.shields.io/badge/-Watch_the_Video-blue?style=for-the-badge&labelColor=black&logo=youtube
26
+ )](https://www.youtube.com/playlist?list=PL85tTROKkZrWyqCcmNCdWajpx05-cTal4)
27
+ [![Demo and Documentation](https://img.shields.io/badge/-Demo_%26_Documentation-blue?style=for-the-badge&labelColor=black&logo=typescript
28
+ )](https://gfazioli.github.io/mantine-clock/)
29
+ [![Mantine Extensions HUB](https://img.shields.io/badge/-Mantine_Extensions_Hub-blue?style=for-the-badge&labelColor=blue
30
+ )](https://mantine-extensions.vercel.app/)
31
+
32
+ 👉 You can find more components on the [Mantine Extensions Hub](https://mantine-extensions.vercel.app/) library.
33
+
34
+
35
+ ## Installation
36
+
37
+ ```sh
38
+ npm install @gfazioli/mantine-clock
39
+ ```
40
+ or
41
+
42
+ ```sh
43
+ yarn add @gfazioli/mantine-clock
44
+ ```
45
+
46
+ After installation import package styles at the root of your application:
47
+
48
+ ```tsx
49
+ import '@gfazioli/mantine-clock/styles.css';
50
+ ```
51
+
52
+ ## Usage
53
+
54
+ The Mantine Clock library provides powerful components and hooks for time management and visualization in React applications using Mantine.
55
+
56
+ ### Clock Component
57
+
58
+ Create analog clocks with real-time updates or static time display:
59
+
60
+ ```tsx
61
+ import { Clock } from '@gfazioli/mantine-clock';
62
+
63
+ // Real-time clock
64
+ function LiveClock() {
65
+ return <Clock />;
66
+ }
67
+
68
+ // Static clock showing specific time
69
+ function StaticClock() {
70
+ return <Clock value={new Date('2023-12-25T15:30:00')} running={false} />;
71
+ }
72
+
73
+ // Customized clock with timezone
74
+ function WorldClock() {
75
+ return (
76
+ <Clock
77
+ timezone="America/New_York"
78
+ showNumbers
79
+ size={200}
80
+ hourHandColor="blue"
81
+ minuteHandColor="cyan"
82
+ secondHandColor="red"
83
+ />
84
+ );
85
+ }
86
+ ```
87
+
88
+ ### useClock Hook
89
+
90
+ Get real-time time data with flexible formatting:
91
+
92
+ ```tsx
93
+ import { useClock } from '@gfazioli/mantine-clock';
94
+
95
+ function DigitalClock() {
96
+ const { hours, minutes, seconds, amPm, isRunning } = useClock({
97
+ timezone: 'UTC',
98
+ use24Hours: false,
99
+ padHours: true,
100
+ padMinutes: true,
101
+ padSeconds: true
102
+ });
103
+
104
+ return (
105
+ <div>
106
+ {hours}:{minutes}:{seconds} {amPm}
107
+ </div>
108
+ );
109
+ }
110
+ ```
111
+
112
+ ### useClockCountDown Hook
113
+
114
+ Create countdown timers with target dates or durations:
115
+
116
+ ```tsx
117
+ import { useClockCountDown } from '@gfazioli/mantine-clock';
118
+
119
+ // Countdown to specific date
120
+ function EventCountdown() {
121
+ const { day, hours, minutes, seconds } = useClockCountDown({
122
+ targetDate: new Date('2024-12-31T23:59:59'),
123
+ onCountDownCompleted: () => alert('Happy New Year!')
124
+ });
125
+
126
+ return (
127
+ <div>
128
+ Time remaining: {day}d {hours}h {minutes}m {seconds}s
129
+ </div>
130
+ );
131
+ }
132
+
133
+ // Countdown from duration
134
+ function TimerCountdown() {
135
+ const { minutes, seconds, isRunning } = useClockCountDown({
136
+ minutes: 25, // 25-minute Pomodoro timer
137
+ onCountDownCompleted: () => console.log('Break time!')
138
+ });
139
+
140
+ return (
141
+ <div>
142
+ Pomodoro: {minutes}:{seconds}
143
+ </div>
144
+ );
145
+ }
146
+ ```
147
+
148
+ ### Styling and Theming
149
+
150
+ The library integrates seamlessly with Mantine's theming system:
151
+
152
+ ```tsx
153
+ import '@gfazioli/mantine-clock/styles.css';
154
+ // or with CSS layers
155
+ import '@gfazioli/mantine-clock/styles.layer.css';
156
+
157
+ // Custom styled clock
158
+ function ThemedClock() {
159
+ return (
160
+ <Clock
161
+ style={{
162
+ '--clock-bg': 'var(--mantine-color-blue-1)',
163
+ '--clock-border': 'var(--mantine-color-blue-6)'
164
+ }}
165
+ className="my-custom-clock"
166
+ />
167
+ );
168
+ }
169
+ ```
170
+
171
+ ### Advanced Examples
172
+
173
+ ```tsx
174
+ // Multi-timezone dashboard
175
+ function WorldClockDashboard() {
176
+ const timezones = [
177
+ { name: 'New York', tz: 'America/New_York' },
178
+ { name: 'London', tz: 'Europe/London' },
179
+ { name: 'Tokyo', tz: 'Asia/Tokyo' }
180
+ ];
181
+
182
+ return (
183
+ <div style={{ display: 'flex', gap: '2rem' }}>
184
+ {timezones.map(({ name, tz }) => (
185
+ <div key={tz}>
186
+ <h3>{name}</h3>
187
+ <Clock timezone={tz} size={150} />
188
+ </div>
189
+ ))}
190
+ </div>
191
+ );
192
+ }
193
+
194
+ // Countdown with controls
195
+ function ControllableCountdown() {
196
+ const countdown = useClockCountDown({
197
+ minutes: 10,
198
+ enabled: false
199
+ });
200
+
201
+ return (
202
+ <div>
203
+ <div>{countdown.minutes}:{countdown.seconds}</div>
204
+ <button onClick={countdown.start}>Start</button>
205
+ <button onClick={countdown.pause}>Pause</button>
206
+ <button onClick={countdown.resume}>Resume</button>
207
+ <button onClick={countdown.reset}>Reset</button>
208
+ </div>
209
+ );
210
+ }
211
+ ```
212
+
213
+ ## Features
214
+
215
+ - **Real-time Updates**: Automatic time synchronization with configurable frequency
216
+ - **Timezone Support**: Global timezone compatibility with IANA timezone database
217
+ - **Customizable Styling**: Full control over appearance and theming
218
+ - **TypeScript Support**: Complete type definitions for better developer experience
219
+ - **Accessibility**: Built with WCAG compliance and screen reader support
220
+ - **Performance Optimized**: Efficient updates with minimal re-renders
221
+ - **Responsive Design**: Adapts to different screen sizes automatically
222
+
223
+
224
+ <div align="center">
225
+
226
+ [![Star History Chart](https://api.star-history.com/svg?repos=gfazioli/mantine-clock&type=Timeline)](https://www.star-history.com/#gfazioli/mantine-clock&Timeline)
227
+
228
+ </div>