react-led-digit 0.0.20 → 0.0.21
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.
- package/README.md +2 -2
- package/lib/BlinkingDigit/BlinkingDigit.d.ts +3 -3
- package/lib/Digit/Digit.d.ts +3 -3
- package/lib/Digit/Digit.stories.d.ts +4 -4
- package/lib/Digit/UnstyledDigit.d.ts +61 -3
- package/lib/Digit/UnstyledDigit.stories.d.ts +2 -2
- package/lib/Digit/components/AmpmSegments.d.ts +3 -3
- package/lib/Digit/components/ColonSegments.d.ts +3 -3
- package/lib/Digit/components/DigitSegments.d.ts +3 -3
- package/lib/Digit/components/DotSegments.d.ts +3 -3
- package/lib/Digit/digit.css +1 -1
- package/lib/Digit/digit.css.generated.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ import { Digit, BlinkingDigit } from 'react-led-digit';
|
|
|
23
23
|
Styled segments example (see [sandbox](https://codesandbox.io/p/sandbox/react-led-digit-forked-c4f2v3)):
|
|
24
24
|
|
|
25
25
|
```tsx
|
|
26
|
-
import { Digit
|
|
26
|
+
import { Digit } from 'react-led-digit';
|
|
27
27
|
|
|
28
28
|
<>
|
|
29
29
|
<Digit
|
|
@@ -33,7 +33,7 @@ import { Digit, BlinkingDigit } from 'react-led-digit';
|
|
|
33
33
|
colorOff: 'blue',
|
|
34
34
|
length: '1em',
|
|
35
35
|
thickness: '.5em',
|
|
36
|
-
|
|
36
|
+
cornerCutoff: '-.1em',
|
|
37
37
|
spacing: '-.1em',
|
|
38
38
|
shiftAD: '.1em',
|
|
39
39
|
opacityOn: 1,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { type DigitProps } from '../Digit';
|
|
3
3
|
import { Blinker } from '../Blinker';
|
|
4
|
-
type
|
|
4
|
+
type BlinkingDigitProps = DigitProps & {
|
|
5
5
|
blinkOptions?: {
|
|
6
6
|
period?: Blinker['period'];
|
|
7
7
|
ratio?: Blinker['ratio'];
|
|
8
8
|
sync?: boolean;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
|
-
export declare const BlinkingDigit: React.MemoExoticComponent<({ blinkOptions, className, ...rest }:
|
|
11
|
+
export declare const BlinkingDigit: React.MemoExoticComponent<({ blinkOptions, className, ...rest }: BlinkingDigitProps) => import("react/jsx-runtime").JSX.Element>;
|
|
12
12
|
export {};
|
package/lib/Digit/Digit.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type
|
|
3
|
-
export declare const Digit: ({ ...rest }:
|
|
1
|
+
import { type DigitProps } from './UnstyledDigit';
|
|
2
|
+
export type { DigitProps } from './UnstyledDigit';
|
|
3
|
+
export declare const Digit: ({ ...rest }: DigitProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { StoryObj } from '@storybook/react';
|
|
2
|
-
import {
|
|
2
|
+
import { type DigitProps } from '../';
|
|
3
3
|
declare const meta: {
|
|
4
4
|
title: string;
|
|
5
|
-
component: ({ ...rest }:
|
|
5
|
+
component: ({ ...rest }: DigitProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
tags: string[];
|
|
7
7
|
parameters: {
|
|
8
8
|
layout: string;
|
|
@@ -17,8 +17,8 @@ export default meta;
|
|
|
17
17
|
type Story = StoryObj<typeof meta>;
|
|
18
18
|
export type DisplayProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
19
19
|
scale?: number;
|
|
20
|
-
shape?:
|
|
21
|
-
segmentStyle?:
|
|
20
|
+
shape?: DigitProps['shape'];
|
|
21
|
+
segmentStyle?: DigitProps['segmentStyle'];
|
|
22
22
|
value: string;
|
|
23
23
|
};
|
|
24
24
|
export declare const Clock: Story;
|
|
@@ -3,25 +3,83 @@ import { SevenSegmentsValue } from './charToSevenSegments';
|
|
|
3
3
|
type NumValue = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
4
4
|
type DigitValue = NumValue | SevenSegmentsValue | 'am' | 'pm' | ':' | '.';
|
|
5
5
|
type DivProps = React.HTMLAttributes<HTMLDivElement>;
|
|
6
|
-
export type
|
|
6
|
+
export type DigitBaseProps = {
|
|
7
|
+
/**
|
|
8
|
+
* When `true`, all segments are dimmed to `opacityOff` (default 0.1),
|
|
9
|
+
* simulating a powered-off LED display.
|
|
10
|
+
*/
|
|
7
11
|
off?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Controls the visual shape of each segment.
|
|
14
|
+
* - `"default"` — diamond for digits, circle for colon/dot, plain text for am/pm
|
|
15
|
+
* - `"rect"` — rectangular segments with sharp corners
|
|
16
|
+
* - `"round"` — segments with fully rounded ends
|
|
17
|
+
* - `"pill"` — capsule-shaped segments (rounded rectangle)
|
|
18
|
+
* - `"calculator"` — angled segments resembling a classic LCD calculator
|
|
19
|
+
*/
|
|
8
20
|
shape?: 'default' | 'rect' | 'round' | 'pill' | 'calculator';
|
|
21
|
+
/**
|
|
22
|
+
* The character to display.
|
|
23
|
+
* - `0`–`9` or a supported letter (e.g. `"L"`, `"H"`) — renders as a 7-segment digit
|
|
24
|
+
* - `":"` — renders as a colon (two vertically stacked dots)
|
|
25
|
+
* - `"."` — renders as a single decimal dot
|
|
26
|
+
* - `"am"` / `"pm"` — renders as an AM/PM indicator
|
|
27
|
+
* - A `SevenSegmentsValue` string — directly specifies which segments to light up
|
|
28
|
+
*/
|
|
9
29
|
value: DigitValue;
|
|
10
30
|
};
|
|
11
31
|
type SegmentStyle = {
|
|
32
|
+
/**
|
|
33
|
+
* Color of active (lit) segments. Overrides the inherited `currentColor`.
|
|
34
|
+
* Accepts any CSS color value (e.g. `"#ff0000"`, `"red"`, `"rgb(0,255,0)"`).
|
|
35
|
+
*/
|
|
12
36
|
color?: CSSProperties['color'];
|
|
37
|
+
/**
|
|
38
|
+
* Color of inactive (unlit) segments. Useful for showing a faint "ghost"
|
|
39
|
+
* outline of the full display. Defaults to the same as `color` at reduced opacity.
|
|
40
|
+
*/
|
|
13
41
|
colorOff?: CSSProperties['color'];
|
|
42
|
+
/**
|
|
43
|
+
* Length of each segment (the longer dimension).
|
|
44
|
+
* Accepts any CSS length value (e.g. `"20px"`, `"1.5em"`).
|
|
45
|
+
*/
|
|
14
46
|
length?: CSSProperties['width'];
|
|
47
|
+
/**
|
|
48
|
+
* Thickness of each segment (the shorter dimension).
|
|
49
|
+
* Accepts any CSS length value (e.g. `"4px"`, `"0.3em"`).
|
|
50
|
+
*/
|
|
15
51
|
thickness?: CSSProperties['width'];
|
|
52
|
+
/**
|
|
53
|
+
* Gap between adjacent segments. Can be negative to overlap segments.
|
|
54
|
+
* Accepts any CSS length value (e.g. `"1px"`, `"-0.5px"`).
|
|
55
|
+
*/
|
|
16
56
|
spacing?: CSSProperties['width'];
|
|
57
|
+
/**
|
|
58
|
+
* Vertical offset applied to the top (A) and bottom (D) horizontal segments,
|
|
59
|
+
* pushing them closer together or farther apart. Useful for fine-tuning
|
|
60
|
+
* the digit's aspect ratio.
|
|
61
|
+
*/
|
|
17
62
|
shiftAD?: CSSProperties['width'];
|
|
63
|
+
/**
|
|
64
|
+
* Opacity of active (lit) segments. Defaults to `1`.
|
|
65
|
+
*/
|
|
18
66
|
opacityOn?: CSSProperties['opacity'];
|
|
67
|
+
/**
|
|
68
|
+
* Opacity of inactive (unlit) segments. Defaults to `0.1`.
|
|
69
|
+
*/
|
|
19
70
|
opacityOff?: CSSProperties['opacity'];
|
|
71
|
+
/**
|
|
72
|
+
* CSS transition duration for segment color and opacity changes.
|
|
73
|
+
* Defaults to `".25s"`. Set to `"0s"` for instant switching.
|
|
74
|
+
*/
|
|
20
75
|
transitionDuration?: CSSProperties['transitionDuration'];
|
|
76
|
+
/**
|
|
77
|
+
* Size of the corner cutoff. Don't applies when `shape` is `"calculator"`.
|
|
78
|
+
*/
|
|
21
79
|
cornerCutoff?: CSSProperties['width'];
|
|
22
80
|
};
|
|
23
|
-
export type
|
|
81
|
+
export type DigitProps = DivProps & DigitBaseProps & {
|
|
24
82
|
segmentStyle?: SegmentStyle;
|
|
25
83
|
};
|
|
26
|
-
export declare const Digit: ({ segmentStyle, value, ...rest }:
|
|
84
|
+
export declare const Digit: ({ segmentStyle, value, ...rest }: DigitProps) => import("react/jsx-runtime").JSX.Element;
|
|
27
85
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { StoryObj } from '@storybook/react';
|
|
2
|
-
import {
|
|
2
|
+
import { type DigitProps } from '..';
|
|
3
3
|
declare const meta: {
|
|
4
4
|
title: string;
|
|
5
|
-
component: ({ segmentStyle, value, ...rest }:
|
|
5
|
+
component: ({ segmentStyle, value, ...rest }: DigitProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
tags: string[];
|
|
7
7
|
parameters: {
|
|
8
8
|
layout: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DigitBaseProps } from '../UnstyledDigit';
|
|
2
2
|
type DivProps = React.HTMLAttributes<HTMLDivElement>;
|
|
3
3
|
export type AmpmSegments = DivProps & {
|
|
4
4
|
className?: string;
|
|
5
|
-
off?:
|
|
6
|
-
shape?:
|
|
5
|
+
off?: DigitBaseProps['off'];
|
|
6
|
+
shape?: DigitBaseProps['shape'];
|
|
7
7
|
AM?: boolean;
|
|
8
8
|
PM?: boolean;
|
|
9
9
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DigitBaseProps } from '../UnstyledDigit';
|
|
2
2
|
type DivProps = React.HTMLAttributes<HTMLDivElement>;
|
|
3
3
|
export type ColonSegments = DivProps & {
|
|
4
4
|
className?: string;
|
|
5
|
-
off?:
|
|
6
|
-
shape?:
|
|
5
|
+
off?: DigitBaseProps['off'];
|
|
6
|
+
shape?: DigitBaseProps['shape'];
|
|
7
7
|
D1?: boolean;
|
|
8
8
|
D2?: boolean;
|
|
9
9
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DigitBaseProps } from '../UnstyledDigit';
|
|
2
2
|
type DivProps = React.HTMLAttributes<HTMLDivElement>;
|
|
3
3
|
export type DigitSegments = DivProps & {
|
|
4
4
|
className?: string;
|
|
5
|
-
off?:
|
|
6
|
-
shape?:
|
|
5
|
+
off?: DigitBaseProps['off'];
|
|
6
|
+
shape?: DigitBaseProps['shape'];
|
|
7
7
|
A?: boolean;
|
|
8
8
|
B?: boolean;
|
|
9
9
|
C?: boolean;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DigitBaseProps } from '../UnstyledDigit';
|
|
2
2
|
type DivProps = React.HTMLAttributes<HTMLDivElement>;
|
|
3
3
|
export type DotSegments = DivProps & {
|
|
4
4
|
className?: string;
|
|
5
|
-
off?:
|
|
6
|
-
shape?:
|
|
5
|
+
off?: DigitBaseProps['off'];
|
|
6
|
+
shape?: DigitBaseProps['shape'];
|
|
7
7
|
DP?: boolean;
|
|
8
8
|
};
|
|
9
9
|
export declare const DotSegments: ({ className, off, shape, DP, ...rest }: DotSegments) => import("react/jsx-runtime").JSX.Element;
|
package/lib/Digit/digit.css
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const css = {
|
|
4
4
|
src: `src/Digit/digit.css`,
|
|
5
|
-
hash: `
|
|
5
|
+
hash: `ru8357il70`,
|
|
6
6
|
content: `
|
|
7
7
|
/**
|
|
8
8
|
* A
|
|
@@ -460,7 +460,7 @@ const css = {
|
|
|
460
460
|
transform: rotate3d(1, -1, 0, 0.025deg);
|
|
461
461
|
}
|
|
462
462
|
|
|
463
|
-
/* better subpixel rendering
|
|
463
|
+
/* better subpixel (16x) rendering for Firefox */
|
|
464
464
|
@-moz-document url-prefix() {
|
|
465
465
|
.digit {
|
|
466
466
|
--scale: 4;
|