typography-controller 1.0.2 → 1.0.3
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/LICENSE +20 -20
- package/README.md +136 -135
- package/dist/react/react-wrapper.js +219 -0
- package/package.json +59 -52
- package/src/typography-controller.js +293 -293
- package/dist/index.html +0 -196
- /package/dist/{typography-controller.js → web/typography-controller.js} +0 -0
- /package/dist/{typography-controller.umd.cjs → web/typography-controller.umd.cjs} +0 -0
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Achuth Kamath
|
|
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
|
|
13
|
-
all 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
|
|
20
|
-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Achuth Kamath
|
|
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
|
|
13
|
+
all 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
|
|
20
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
21
21
|
DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,135 +1,136 @@
|
|
|
1
|
-
# Typography Controller
|
|
2
|
-
|
|
3
|
-
A framework
|
|
4
|
-
font size, letter spacing, word spacing, line height, contrast, and font family.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
1
|
+
# Typography Controller
|
|
2
|
+
|
|
3
|
+
A lightweight, framework‑agnostic Web Component that provides a beautiful, interactive typography control panel.
|
|
4
|
+
Adjust font size, letter spacing, word spacing, line height, contrast, and font family — all in real time.
|
|
5
|
+
|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
## 🚀 Features
|
|
9
|
+
|
|
10
|
+
- Font Size: Adjust the font size with a slider (range: 12-48px).
|
|
11
|
+
- Letter Spacing: Control the spacing between characters.
|
|
12
|
+
- Word Spacing: Adjust spacing between words.
|
|
13
|
+
- Line Height: Set the line height (1-3).
|
|
14
|
+
- Contrast: Apply a contrast filter (50-200%).
|
|
15
|
+
- Font Family: Choose from predefined fonts (Arial, Georgia, Courier New, Verdana).
|
|
16
|
+
- Framework‑agnostic — Works in HTML, React, Vue, Svelte, etc.
|
|
17
|
+
- Public API — getValues(), setValues(), setFeatures(), and change events.
|
|
18
|
+
|
|
19
|
+
## 📦 Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install typography-controller
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
1. Import the component
|
|
28
|
+
|
|
29
|
+
```html
|
|
30
|
+
import "typography-controller/dist/typography-controller.js";
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
2. Add the `<typography-controller>` element to your HTML, specifying the target element via the `target` attribute:
|
|
34
|
+
|
|
35
|
+
```html
|
|
36
|
+
<h2 id="myText">This is the text to style.</h2>
|
|
37
|
+
<typography-controller target="#myText"></typography-controller>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## 🌐 Using via CDN (no bundler)
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
<script type="module" src="https://unpkg.com/typography-controller/dist/typography-controller.js"></script>
|
|
44
|
+
|
|
45
|
+
<h2 id="demo">Hello World</h2>
|
|
46
|
+
<typography-controller target="#demo"></typography-controller>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## 📚 JavaScript API
|
|
50
|
+
|
|
51
|
+
### Methods
|
|
52
|
+
| Method | Description | Parameters/Return |
|
|
53
|
+
|--------|-------------|-------------------|
|
|
54
|
+
| getValues() | Returns the current typography values as an object. | Returns: `{ fontSize: number, letterSpacing: number, wordSpacing: number, lineHeight: number, contrast: number, fontFamily: string }` |
|
|
55
|
+
| setValues(values) | Sets the typography values programmatically. | Parameters: `values` (object with keys like `fontSize`, `letterSpacing`, etc.) |
|
|
56
|
+
| setFeatures(features) | Enables or disables specific features (e.g., sliders). | Parameters: `features` (object with boolean keys like `letterSpacing: true`) |
|
|
57
|
+
|
|
58
|
+
### Events
|
|
59
|
+
| Event | Description | Detail |
|
|
60
|
+
|-------|-------------|--------|
|
|
61
|
+
| change | Fired whenever a value changes via the UI or API. | `event.detail`: Object containing updated values (same as `getValues()` return). |
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
Example
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
const controller = document.querySelector("typography-controller");
|
|
68
|
+
|
|
69
|
+
controller.addEventListener("change", (e) => {
|
|
70
|
+
console.log("Updated values:", e.detail);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
controller.setValues({
|
|
74
|
+
fontSize: 30,
|
|
75
|
+
letterSpacing: 2,
|
|
76
|
+
fontFamily: "Georgia"
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## ⚛️ React Usage
|
|
81
|
+
|
|
82
|
+
Basic usage
|
|
83
|
+
```
|
|
84
|
+
import "typography-controller/dist/typography-controller.js";
|
|
85
|
+
|
|
86
|
+
export default function App() {
|
|
87
|
+
return (
|
|
88
|
+
<div>
|
|
89
|
+
<h2 id="demoText">Typography should feel like breathing space.</h2>
|
|
90
|
+
|
|
91
|
+
<typography-controller
|
|
92
|
+
target="#demoText"
|
|
93
|
+
hide-letter-spacing
|
|
94
|
+
onChange={(e) => console.log(e.detail)}
|
|
95
|
+
></typography-controller>
|
|
96
|
+
</div>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Using JS API (setFeatures, setValues) with refs
|
|
102
|
+
```
|
|
103
|
+
import { useRef, useEffect } from "react";
|
|
104
|
+
import "typography-controller/dist/typography-controller.js";
|
|
105
|
+
|
|
106
|
+
export default function App() {
|
|
107
|
+
const ref = useRef();
|
|
108
|
+
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
if (ref.current) {
|
|
111
|
+
ref.current.setFeatures({
|
|
112
|
+
letterSpacing: true,
|
|
113
|
+
wordSpacing: false,
|
|
114
|
+
lineHeight: true,
|
|
115
|
+
contrast: true
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}, []);
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<>
|
|
122
|
+
<h2 id="demoText">Hello world</h2>
|
|
123
|
+
|
|
124
|
+
<typography-controller
|
|
125
|
+
ref={ref}
|
|
126
|
+
target="#demoText"
|
|
127
|
+
onChange={(e) => console.log(e.detail)}
|
|
128
|
+
></typography-controller>
|
|
129
|
+
</>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## License
|
|
135
|
+
|
|
136
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { createComponent as o } from "@lit/react";
|
|
2
|
+
import a from "react";
|
|
3
|
+
let n = class extends HTMLElement {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(), this.attachShadow({ mode: "open" }), this.shadowRoot.innerHTML = `
|
|
6
|
+
<style>
|
|
7
|
+
:host {
|
|
8
|
+
display: block;
|
|
9
|
+
font-family: system-ui, sans-serif;
|
|
10
|
+
max-width: 420px;
|
|
11
|
+
padding: 18px 20px;
|
|
12
|
+
border-radius: 18px;
|
|
13
|
+
background: rgba(255, 255, 255, 0.65);
|
|
14
|
+
border: 1px solid rgba(0, 0, 0, 0.08);
|
|
15
|
+
backdrop-filter: blur(14px);
|
|
16
|
+
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
|
|
17
|
+
color: #0f172a;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.header {
|
|
21
|
+
display: flex;
|
|
22
|
+
justify-content: space-between;
|
|
23
|
+
align-items: baseline;
|
|
24
|
+
margin-bottom: 14px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.title {
|
|
28
|
+
font-size: 14px;
|
|
29
|
+
font-weight: 600;
|
|
30
|
+
letter-spacing: 0.08em;
|
|
31
|
+
text-transform: uppercase;
|
|
32
|
+
color: #475569;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.badge {
|
|
36
|
+
font-size: 11px;
|
|
37
|
+
padding: 3px 8px;
|
|
38
|
+
border-radius: 999px;
|
|
39
|
+
background: rgba(59, 130, 246, 0.12);
|
|
40
|
+
color: #1d4ed8;
|
|
41
|
+
border: 1px solid rgba(59, 130, 246, 0.35);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.group {
|
|
45
|
+
margin-bottom: 14px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.label-row {
|
|
49
|
+
display: flex;
|
|
50
|
+
justify-content: space-between;
|
|
51
|
+
align-items: center;
|
|
52
|
+
margin-bottom: 6px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
label {
|
|
56
|
+
font-size: 12px;
|
|
57
|
+
font-weight: 600;
|
|
58
|
+
color: #0f172a;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.value {
|
|
62
|
+
font-size: 11px;
|
|
63
|
+
color: #64748b;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
input[type="range"] {
|
|
67
|
+
-webkit-appearance: none;
|
|
68
|
+
width: 100%;
|
|
69
|
+
height: 6px;
|
|
70
|
+
border-radius: 999px;
|
|
71
|
+
background: linear-gradient(90deg, #3b82f6, #60a5fa);
|
|
72
|
+
outline: none;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
input[type="range"]::-webkit-slider-thumb {
|
|
76
|
+
-webkit-appearance: none;
|
|
77
|
+
height: 18px;
|
|
78
|
+
width: 18px;
|
|
79
|
+
border-radius: 50%;
|
|
80
|
+
background: white;
|
|
81
|
+
border: 1px solid rgba(0, 0, 0, 0.15);
|
|
82
|
+
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
|
|
83
|
+
cursor: pointer;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
select {
|
|
87
|
+
width: 100%;
|
|
88
|
+
padding: 6px 8px;
|
|
89
|
+
border-radius: 8px;
|
|
90
|
+
border: 1px solid rgba(148, 163, 184, 0.7);
|
|
91
|
+
background: rgba(255, 255, 255, 0.9);
|
|
92
|
+
font-size: 12px;
|
|
93
|
+
color: #0f172a;
|
|
94
|
+
outline: none;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
select:focus {
|
|
98
|
+
border-color: #2563eb;
|
|
99
|
+
box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.4);
|
|
100
|
+
}
|
|
101
|
+
</style>
|
|
102
|
+
|
|
103
|
+
<div class="header">
|
|
104
|
+
<div class="title">Typography Controls</div>
|
|
105
|
+
<div class="badge">Web Component</div>
|
|
106
|
+
</div>
|
|
107
|
+
|
|
108
|
+
<div class="group" id="groupFontSize">
|
|
109
|
+
<div class="label-row">
|
|
110
|
+
<label for="fontSize">Font size</label>
|
|
111
|
+
<span class="value" id="fontSizeValue"></span>
|
|
112
|
+
</div>
|
|
113
|
+
<input type="range" id="fontSize" min="12" max="60" value="24">
|
|
114
|
+
</div>
|
|
115
|
+
|
|
116
|
+
<div class="group" id="groupLetterSpacing">
|
|
117
|
+
<div class="label-row">
|
|
118
|
+
<label for="letterSpacing">Letter spacing</label>
|
|
119
|
+
<span class="value" id="letterSpacingValue"></span>
|
|
120
|
+
</div>
|
|
121
|
+
<input type="range" id="letterSpacing" min="0" max="20" value="0">
|
|
122
|
+
</div>
|
|
123
|
+
|
|
124
|
+
<div class="group" id="groupWordSpacing">
|
|
125
|
+
<div class="label-row">
|
|
126
|
+
<label for="wordSpacing">Word spacing</label>
|
|
127
|
+
<span class="value" id="wordSpacingValue"></span>
|
|
128
|
+
</div>
|
|
129
|
+
<input type="range" id="wordSpacing" min="0" max="40" value="0">
|
|
130
|
+
</div>
|
|
131
|
+
|
|
132
|
+
<div class="group" id="groupLineHeight">
|
|
133
|
+
<div class="label-row">
|
|
134
|
+
<label for="lineHeight">Line height</label>
|
|
135
|
+
<span class="value" id="lineHeightValue"></span>
|
|
136
|
+
</div>
|
|
137
|
+
<input type="range" id="lineHeight" min="1" max="3" step="0.1" value="1.5">
|
|
138
|
+
</div>
|
|
139
|
+
|
|
140
|
+
<div class="group" id="groupContrast">
|
|
141
|
+
<div class="label-row">
|
|
142
|
+
<label for="contrast">Contrast</label>
|
|
143
|
+
<span class="value" id="contrastValue"></span>
|
|
144
|
+
</div>
|
|
145
|
+
<input type="range" id="contrast" min="50" max="200" value="100">
|
|
146
|
+
</div>
|
|
147
|
+
|
|
148
|
+
<div class="group" id="groupFontFamily">
|
|
149
|
+
<div class="label-row">
|
|
150
|
+
<label for="fontFamily">Font family</label>
|
|
151
|
+
</div>
|
|
152
|
+
<select id="fontFamily">
|
|
153
|
+
<option value="system-ui, sans-serif">System</option>
|
|
154
|
+
<option value="Georgia, serif">Serif</option>
|
|
155
|
+
<option value="'Courier New', monospace">Monospace</option>
|
|
156
|
+
<option value="Verdana, sans-serif">Verdana</option>
|
|
157
|
+
</select>
|
|
158
|
+
</div>
|
|
159
|
+
`;
|
|
160
|
+
}
|
|
161
|
+
connectedCallback() {
|
|
162
|
+
this.targetSelector = this.getAttribute("target"), this.toggleGroup("#groupLetterSpacing", !this.hasAttribute("hide-letter-spacing")), this.toggleGroup("#groupWordSpacing", !this.hasAttribute("hide-word-spacing")), this.toggleGroup("#groupLineHeight", !this.hasAttribute("hide-line-height")), this.toggleGroup("#groupContrast", !this.hasAttribute("hide-contrast")), this.fontSize = this.shadowRoot.querySelector("#fontSize"), this.letterSpacing = this.shadowRoot.querySelector("#letterSpacing"), this.wordSpacing = this.shadowRoot.querySelector("#wordSpacing"), this.lineHeight = this.shadowRoot.querySelector("#lineHeight"), this.contrast = this.shadowRoot.querySelector("#contrast"), this.fontFamily = this.shadowRoot.querySelector("#fontFamily");
|
|
163
|
+
const t = this.targetElement;
|
|
164
|
+
if (t) {
|
|
165
|
+
const i = getComputedStyle(t).fontFamily;
|
|
166
|
+
this.fontFamily.value = i;
|
|
167
|
+
}
|
|
168
|
+
this.fontSizeValue = this.shadowRoot.querySelector("#fontSizeValue"), this.letterSpacingValue = this.shadowRoot.querySelector("#letterSpacingValue"), this.wordSpacingValue = this.shadowRoot.querySelector("#wordSpacingValue"), this.lineHeightValue = this.shadowRoot.querySelector("#lineHeightValue"), this.contrastValue = this.shadowRoot.querySelector("#contrastValue");
|
|
169
|
+
const e = () => {
|
|
170
|
+
this.update(), this.dispatchEvent(
|
|
171
|
+
new CustomEvent("change", {
|
|
172
|
+
detail: this.getValues(),
|
|
173
|
+
bubbles: !0,
|
|
174
|
+
composed: !0
|
|
175
|
+
})
|
|
176
|
+
);
|
|
177
|
+
};
|
|
178
|
+
this.fontSize.addEventListener("input", e), this.letterSpacing.addEventListener("input", e), this.wordSpacing.addEventListener("input", e), this.lineHeight.addEventListener("input", e), this.contrast.addEventListener("input", e), this.fontFamily.addEventListener("change", e), this.update();
|
|
179
|
+
}
|
|
180
|
+
toggleGroup(t, e) {
|
|
181
|
+
const i = this.shadowRoot.querySelector(t);
|
|
182
|
+
i && (i.style.display = e ? "block" : "none");
|
|
183
|
+
}
|
|
184
|
+
get targetElement() {
|
|
185
|
+
return document.querySelector(this.targetSelector);
|
|
186
|
+
}
|
|
187
|
+
update() {
|
|
188
|
+
const t = this.targetElement;
|
|
189
|
+
t && (t.style.fontSize = `${this.fontSize.value}px`, t.style.letterSpacing = `${this.letterSpacing.value}px`, t.style.wordSpacing = `${this.wordSpacing.value}px`, t.style.lineHeight = this.lineHeight.value, t.style.filter = `contrast(${this.contrast.value}%)`, t.style.fontFamily = this.fontFamily.value, this.fontSizeValue.textContent = `${this.fontSize.value}px`, this.letterSpacingValue.textContent = `${this.letterSpacing.value}px`, this.wordSpacingValue.textContent = `${this.wordSpacing.value}px`, this.lineHeightValue.textContent = this.lineHeight.value, this.contrastValue.textContent = `${this.contrast.value}%`);
|
|
190
|
+
}
|
|
191
|
+
getValues() {
|
|
192
|
+
return {
|
|
193
|
+
fontSize: Number(this.fontSize.value),
|
|
194
|
+
letterSpacing: Number(this.letterSpacing.value),
|
|
195
|
+
wordSpacing: Number(this.wordSpacing.value),
|
|
196
|
+
lineHeight: Number(this.lineHeight.value),
|
|
197
|
+
contrast: Number(this.contrast.value),
|
|
198
|
+
fontFamily: this.fontFamily.value
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
setValues(t = {}) {
|
|
202
|
+
t.fontSize !== void 0 && (this.fontSize.value = t.fontSize), t.letterSpacing !== void 0 && (this.letterSpacing.value = t.letterSpacing), t.wordSpacing !== void 0 && (this.wordSpacing.value = t.wordSpacing), t.lineHeight !== void 0 && (this.lineHeight.value = t.lineHeight), t.contrast !== void 0 && (this.contrast.value = t.contrast), t.fontFamily !== void 0 && (this.fontFamily.value = t.fontFamily), this.update();
|
|
203
|
+
}
|
|
204
|
+
setFeatures(t = {}) {
|
|
205
|
+
t.letterSpacing !== void 0 && (this.toggleGroup("#groupLetterSpacing", t.letterSpacing), t.letterSpacing ? this.removeAttribute("hide-letter-spacing") : this.setAttribute("hide-letter-spacing", "")), t.wordSpacing !== void 0 && (this.toggleGroup("#groupWordSpacing", t.wordSpacing), t.wordSpacing ? this.removeAttribute("hide-word-spacing") : this.setAttribute("hide-word-spacing", "")), t.lineHeight !== void 0 && (this.toggleGroup("#groupLineHeight", t.lineHeight), t.lineHeight ? this.removeAttribute("hide-line-height") : this.setAttribute("hide-line-height", "")), t.contrast !== void 0 && (this.toggleGroup("#groupContrast", t.contrast), t.contrast ? this.removeAttribute("hide-contrast") : this.setAttribute("hide-contrast", ""));
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
customElements.define("typography-controller", n);
|
|
209
|
+
const d = o({
|
|
210
|
+
react: a,
|
|
211
|
+
tagName: "typography-controller",
|
|
212
|
+
elementClass: customElements.get("typography-controller"),
|
|
213
|
+
events: {
|
|
214
|
+
onChange: "change"
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
export {
|
|
218
|
+
d as TypographyController
|
|
219
|
+
};
|
package/package.json
CHANGED
|
@@ -1,52 +1,59 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "typography-controller",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "A framework-agnostic Web Component that provides a beautiful typography control panel with sliders for font size, letter spacing, word spacing, line height, contrast, and font family.",
|
|
5
|
-
"author": "Achuth Kamath",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"type": "module",
|
|
8
|
-
"main": "dist/typography-controller.js",
|
|
9
|
-
"module": "dist/typography-controller.js",
|
|
10
|
-
"source": "src/typography-controller.js",
|
|
11
|
-
"exports": {
|
|
12
|
-
".": "./dist/typography-controller.js",
|
|
13
|
-
"./react": "./dist/react-wrapper.js"
|
|
14
|
-
},
|
|
15
|
-
"files": [
|
|
16
|
-
"dist",
|
|
17
|
-
"src",
|
|
18
|
-
"README.md",
|
|
19
|
-
"LICENSE"
|
|
20
|
-
],
|
|
21
|
-
"scripts": {
|
|
22
|
-
"dev": "vite",
|
|
23
|
-
"build": "vite build",
|
|
24
|
-
"preview": "vite preview"
|
|
25
|
-
},
|
|
26
|
-
"keywords": [
|
|
27
|
-
"web-components",
|
|
28
|
-
"custom-elements",
|
|
29
|
-
"typography",
|
|
30
|
-
"ui",
|
|
31
|
-
"ui-library",
|
|
32
|
-
"accessibility",
|
|
33
|
-
"design-system",
|
|
34
|
-
"frontend",
|
|
35
|
-
"javascript"
|
|
36
|
-
],
|
|
37
|
-
"homepage": "https://github.com/
|
|
38
|
-
"repository": {
|
|
39
|
-
"type": "git",
|
|
40
|
-
"url": "https://github.com/
|
|
41
|
-
},
|
|
42
|
-
"bugs": {
|
|
43
|
-
"url": "https://github.com/
|
|
44
|
-
},
|
|
45
|
-
"devDependencies": {
|
|
46
|
-
"@
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "typography-controller",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "A framework-agnostic Web Component that provides a beautiful typography control panel with sliders for font size, letter spacing, word spacing, line height, contrast, and font family.",
|
|
5
|
+
"author": "Achuth Kamath",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "dist/web/typography-controller.js",
|
|
9
|
+
"module": "dist/web/typography-controller.js",
|
|
10
|
+
"source": "src/typography-controller.js",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": "./dist/web/typography-controller.js",
|
|
13
|
+
"./react": "./dist/react/react-wrapper.js"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"src",
|
|
18
|
+
"README.md",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"dev": "vite",
|
|
23
|
+
"build": "vite build && vite build --config react.vite.config.js",
|
|
24
|
+
"preview": "vite preview"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"web-components",
|
|
28
|
+
"custom-elements",
|
|
29
|
+
"typography",
|
|
30
|
+
"ui",
|
|
31
|
+
"ui-library",
|
|
32
|
+
"accessibility",
|
|
33
|
+
"design-system",
|
|
34
|
+
"frontend",
|
|
35
|
+
"javascript"
|
|
36
|
+
],
|
|
37
|
+
"homepage": "https://github.com/achuthkamath91/Typography-Controller",
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "https://github.com/achuthkamath91/Typography-Controller.git"
|
|
41
|
+
},
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/achuthkamath91/Typography-Controller/issues"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
47
|
+
"@semantic-release/commit-analyzer": "^13.0.0",
|
|
48
|
+
"@semantic-release/git": "^10.0.1",
|
|
49
|
+
"@semantic-release/github": "^12.0.3",
|
|
50
|
+
"@semantic-release/npm": "^13.1.3",
|
|
51
|
+
"@semantic-release/release-notes-generator": "^14.0.1",
|
|
52
|
+
"@vitejs/plugin-react": "^5.1.2",
|
|
53
|
+
"semantic-release": "^25.0.3",
|
|
54
|
+
"vite": "^5.4.21"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"user": "^0.0.0"
|
|
58
|
+
}
|
|
59
|
+
}
|