kempo-ui 0.0.82 → 0.0.83

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 (2) hide show
  1. package/package.json +1 -1
  2. package/CONTRIBUTING.md +0 -219
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kempo-ui",
3
- "version": "0.0.82",
3
+ "version": "0.0.83",
4
4
  "type": "module",
5
5
  "description": "A Lit based web-component library",
6
6
  "main": "index.js",
package/CONTRIBUTING.md DELETED
@@ -1,219 +0,0 @@
1
- # Code Contribution Guidelines
2
-
3
- ## Project Structure
4
-
5
- - All code should be in the `src/` directory, with the exception of npm scripts.
6
- - All components should be in the `src/components/` directory.
7
- - All utility function module files should be in the `src/utils/` directory.
8
- - All documnentation should be in the `docs/` directory. This directory is used by GitHub as the "GitHub Pages", so all links need to be relative, and there will be a build script which copies all code to the `docs/` directory.
9
-
10
- ## Coding Style Guidelines
11
-
12
- ### Code Organization
13
- Use multi-line comments to separate code into logical sections. Group related functionality together.
14
- - Example: In Lit components, group lifecycle callbacks, event handlers, public methods, utility functions, and rendering logic separately.
15
-
16
- ```javascript
17
- /*
18
- Lifecycle Callbacks
19
- */
20
- ```
21
-
22
- ### Avoid single-use variables/functions
23
- Avoid defining a variable or function to only use it once; inline the logic where needed. Some exceptions include:
24
- - recursion
25
- - scope encapsulation (IIFE)
26
- - context changes
27
-
28
- ### Minimal Comments, Empty Lines, and Spacing
29
-
30
- Use minimal comments. Assume readers understand the language. Some exceptions include:
31
- - complex logic
32
- - anti-patterns
33
- - code organization
34
-
35
- Do not put random empty lines within code; put them where they make sense for readability, for example:
36
- - above and below definitions for functions and classes.
37
- - to help break up large sections of logic to be more readable. If there are 100 lines of code with no breaks, it gets hard to read.
38
- - above multi-line comments to indicate the comment belongs to the code below
39
-
40
- No empty lines in css.
41
-
42
- End each file with an empty line.
43
-
44
- End each line with a `;` when possible, even if it is optional.
45
-
46
- Avoid unnecessary spacing, for example:
47
- - after the word `if`
48
- - within parentheses for conditional statements
49
-
50
- ```javascript
51
- let count = 1;
52
-
53
- const incrementOdd = (n) => {
54
- if(n % 2 !== 0){
55
- return n++;
56
- }
57
- return n;
58
- };
59
-
60
- count = incrementOdd(count);
61
- ```
62
-
63
- ### Prefer Arrow Functions
64
- Prefer the use of arrow functions when possible, especially for class methods to avoid binding. Use normal functions if needed for preserving the proper context.
65
- - For very basic logic, use implicit returns
66
- - If there is a single parameter, omit the parentheses.
67
- ```javascript
68
- const addOne = n => n + 1;
69
- ```
70
-
71
- ### Module Exports
72
- - If a module has only one export, use the "default" export, not a named export.
73
- - Do not declare the default export as a const or give it a name; just export the value.
74
-
75
- ```javascript
76
- export default (n) => n + 1;
77
- ```
78
- - If a module has multiple exports, use named exports and do not use a "default" export.
79
-
80
- ### Code Reuse
81
- Create utility functions for shared logic.
82
- - If the shared logic is used in a single file, define a utility function in that file.
83
- - If the shared logic is used in multiple files, create a utility function module file in `src/utils/`.
84
-
85
- ### Naming
86
- Do not prefix identifiers with underscores.
87
- - Never use leading underscores (`_`) for variable, property, method, or function names.
88
- - Use clear, descriptive names without prefixes.
89
- - When true privacy is needed inside classes, prefer native JavaScript private fields (e.g., `#myField`) instead of simulated privacy via underscores.
90
-
91
- ## Components
92
-
93
- ### Base Component Architecture
94
-
95
- The project provides three base components for different rendering strategies. Choose the appropriate base component and extend it:
96
-
97
- #### ShadowComponent
98
- For components that need shadow DOM encapsulation and automatic `/kempo.css` stylesheet injection.
99
-
100
- ```javascript
101
- import ShadowComponent from './ShadowComponent.js';
102
-
103
- export default class MyComponent extends ShadowComponent {
104
- render() {
105
- return html`<p>Shadow DOM content with scoped styles</p>`;
106
- }
107
- }
108
- ```
109
-
110
- #### LightComponent
111
- For components that render directly to light DOM without shadow DOM encapsulation.
112
-
113
- ```javascript
114
- import LightComponent from './LightComponent.js';
115
-
116
- export default class MyComponent extends LightComponent {
117
- renderLightDom() {
118
- return html`<p>Light DOM content</p>`;
119
- }
120
- }
121
- ```
122
-
123
- #### HybridComponent
124
- For components that need both shadow DOM (with automatic `/kempo.css`) and light DOM rendering.
125
-
126
- ```javascript
127
- import HybridComponent from './HybridComponent.js';
128
-
129
- export default class MyComponent extends HybridComponent {
130
- render() {
131
- return html`<p>Shadow DOM content</p>`;
132
- }
133
-
134
- renderLightDom() {
135
- return html`<p>Light DOM content alongside natural children</p>`;
136
- }
137
- }
138
- ```
139
-
140
- **Important:** Always call `super.updated()` when overriding the `updated()` method in LightComponent or HybridComponent to ensure proper rendering.
141
-
142
- ### Component Architecture and Communication
143
-
144
- - Use methods to cause actions; do not emit events to trigger logic. Events are for notifying that something already happened.
145
- - Prefer `el.closest('ktf-test-framework')?.enqueueSuite({...})` over firing an `enqueue` event.
146
-
147
- - Wrap dependent components inside a parent `ktf-test-framework` element. Children find it via `closest('ktf-test-framework')` and call its methods. The framework can query its subtree to orchestrate children.
148
-
149
- - Avoid `window` globals and global custom events for coordination. If broadcast is needed, scope events to the framework element; reserve window events for global, non-visual concerns (e.g., settings changes).
150
-
151
- ## Development Workflow
152
-
153
- ### NPM Scripts
154
-
155
- #### Build
156
- ```bash
157
- npm run build
158
- ```
159
- Compiles and minifies source files from `src/` and copies all necessary files to the `docs/` directory for GitHub Pages deployment.
160
-
161
- #### Documentation Server
162
- ```bash
163
- npm run docs
164
- ```
165
- Starts a local development server and opens the documentation site. Automatically runs the build script first.
166
-
167
- **Variants:**
168
- - `npm run docs:src` - Serves from `src/` instead of `docs/` for development
169
- - `npm run docs:no-build` - Skips the build step and serves existing `docs/`
170
-
171
- #### Testing
172
- ```bash
173
- npm test # Run all tests
174
- npm run test:gui # Run tests with GUI interface
175
- npm run test:browser # Run browser-only tests
176
- npm run test:node # Run Node.js-only tests
177
- ```
178
-
179
- #### Update Kempo CSS
180
- ```bash
181
- npm run update-kempo-css
182
- ```
183
- Downloads the latest version of Kempo CSS from the CDN and updates local files.
184
-
185
- ### Adding Icons
186
-
187
- Use the `geticon` script to download icons from [Google Material Symbols](https://fonts.google.com/icons). The script automatically formats icons and triggers a build.
188
-
189
- #### Basic Usage
190
- ```bash
191
- npm run geticon <icon_name>
192
- ```
193
-
194
- Example:
195
- ```bash
196
- npm run geticon format_bold
197
- ```
198
-
199
- This downloads the icon and saves it as `format_bold.svg` in the `icons/` directory.
200
-
201
- #### Custom Naming
202
-
203
- Rename icons when downloading by providing a second argument:
204
- ```bash
205
- npm run geticon <icon_name> <custom_name>
206
- ```
207
-
208
- Example - download `content_copy` but save as `copy.svg`:
209
- ```bash
210
- npm run geticon content_copy copy
211
- ```
212
-
213
- #### What the Script Does
214
-
215
- - Downloads the specified icon from Google's Material Symbols CDN
216
- - Removes `width` and `height` attributes
217
- - Adds `fill="currentColor"` to all `<path>` elements
218
- - Saves the formatted SVG to the `icons/` directory
219
- - Automatically runs the build script to copy the icon to `docs/`