mirror of
				https://github.com/jaandrle/deka-dom-el
				synced 2025-10-31 13:59:14 +01:00 
			
		
		
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			main
			...
			3301a6600c
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 3301a6600c | 
							
								
								
									
										40
									
								
								.github/ISSUE_TEMPLATE/bug_report.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								.github/ISSUE_TEMPLATE/bug_report.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,40 @@ | |||||||
|  | --- | ||||||
|  | name: Bug report | ||||||
|  | about: Create a report to help us improve | ||||||
|  | title: ":bug: " | ||||||
|  | labels: bug | ||||||
|  | assignees: '' | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | ## Bug Description | ||||||
|  | <!-- A clear and concise description of what the bug is --> | ||||||
|  |  | ||||||
|  | ## Steps to Reproduce | ||||||
|  | <!-- Steps to reproduce the behavior --> | ||||||
|  | 1.  | ||||||
|  | 2.  | ||||||
|  | 3.  | ||||||
|  |  | ||||||
|  | ## Expected Behavior | ||||||
|  | <!-- A clear and concise description of what you expected to happen --> | ||||||
|  |  | ||||||
|  | ## Actual Behavior | ||||||
|  | <!-- A clear and concise description of what actually happened --> | ||||||
|  |  | ||||||
|  | ## Code Sample | ||||||
|  | <!-- If applicable, add minimal code sample to reproduce the issue --> | ||||||
|  | ```js | ||||||
|  | // Your code here | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Environment | ||||||
|  | - Browser and version: <!-- e.g. Chrome 120, Firefox 120, Safari 17 --> | ||||||
|  | - OS: <!-- e.g. Windows 11, macOS Sonoma, Ubuntu 22.04 --> | ||||||
|  | - dd<el> version: <!-- e.g. 0.9.2 --> | ||||||
|  | - Other relevant details: | ||||||
|  |  | ||||||
|  | ## Screenshots | ||||||
|  | <!-- If applicable, add screenshots to help explain your problem --> | ||||||
|  |  | ||||||
|  | ## Additional Context | ||||||
|  | <!-- Add any other context about the problem here --> | ||||||
							
								
								
									
										22
									
								
								.github/ISSUE_TEMPLATE/documentation.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								.github/ISSUE_TEMPLATE/documentation.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | |||||||
|  | --- | ||||||
|  | name: Documentation improvement | ||||||
|  | about: Suggest improvements to the documentation | ||||||
|  | title: ":abc: " | ||||||
|  | labels: documentation | ||||||
|  | assignees: '' | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | ## Documentation Area | ||||||
|  | <!-- Which part of the documentation needs improvement? Provide links if applicable --> | ||||||
|  |  | ||||||
|  | ## Current Issue | ||||||
|  | <!-- What's currently unclear, missing, or incorrect in the documentation? --> | ||||||
|  |  | ||||||
|  | ## Suggested Improvement | ||||||
|  | <!-- Describe the improvement or addition you'd like to see --> | ||||||
|  |  | ||||||
|  | ## Example Content | ||||||
|  | <!-- If applicable, provide example content or wording --> | ||||||
|  |  | ||||||
|  | ## Additional Context | ||||||
|  | <!-- Any other context or screenshots about the documentation request --> | ||||||
							
								
								
									
										29
									
								
								.github/ISSUE_TEMPLATE/feature_request.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								.github/ISSUE_TEMPLATE/feature_request.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,29 @@ | |||||||
|  | --- | ||||||
|  | name: Feature request | ||||||
|  | about: Suggest an idea for this project | ||||||
|  | title: ":zap: " | ||||||
|  | labels: enhancement | ||||||
|  | assignees: '' | ||||||
|  | --- | ||||||
|  | <!-- Consider open discussion: https://github.com/jaandrle/deka-dom-el/discussions first --> | ||||||
|  |  | ||||||
|  | ## Problem Statement | ||||||
|  | <!-- A clear and concise description of the problem this feature would solve --> | ||||||
|  |  | ||||||
|  | ## Proposed Solution | ||||||
|  | <!-- A detailed description of the feature you're suggesting --> | ||||||
|  |  | ||||||
|  | ## Use Cases | ||||||
|  | <!-- Describe specific use cases where this feature would be beneficial --> | ||||||
|  |  | ||||||
|  | ## Example Implementation | ||||||
|  | <!-- If possible, provide example code or pseudocode for how this feature might work --> | ||||||
|  | ```js | ||||||
|  | // Example code | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Alternatives Considered | ||||||
|  | <!-- A description of any alternative solutions or features you've considered --> | ||||||
|  |  | ||||||
|  | ## Additional Context | ||||||
|  | <!-- Any other context, screenshots, or examples that might be helpful --> | ||||||
							
								
								
									
										39
									
								
								.github/pull_request_template.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								.github/pull_request_template.md
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,39 @@ | |||||||
|  | <!--  | ||||||
|  | Please use an appropriate git3moji in your PR title: https://robinpokorny.github.io/git3moji/ | ||||||
|  | Examples: | ||||||
|  | - :bug: Fix signal update not triggering on nested properties | ||||||
|  | - :zap: Improve event delegation performance | ||||||
|  | - :abc: Add documentation for custom elements | ||||||
|  | --> | ||||||
|  |  | ||||||
|  | ## Description | ||||||
|  | <!-- Describe the changes introduced by this PR --> | ||||||
|  |  | ||||||
|  | ## Related Issues | ||||||
|  | <!-- Link any related issues using the format #ISSUE_NUMBER --> | ||||||
|  |  | ||||||
|  | ## Type of Change | ||||||
|  | - [ ] Bug fix (non-breaking change that fixes an issue) | ||||||
|  | - [ ] New feature (non-breaking change that adds functionality) | ||||||
|  | - [ ] Breaking change (fix or feature that would cause existing functionality to change) | ||||||
|  | - [ ] Documentation update | ||||||
|  | - [ ] Code refactoring | ||||||
|  | - [ ] Performance improvement | ||||||
|  | - [ ] Test update | ||||||
|  |  | ||||||
|  | ## Testing Performed | ||||||
|  | <!-- Describe the tests you've done to verify your changes --> | ||||||
|  |  | ||||||
|  | ## Screenshots | ||||||
|  | <!-- If applicable, add screenshots to help explain your changes --> | ||||||
|  |  | ||||||
|  | ## Checklist | ||||||
|  | - [ ] My code follows the code style of this project | ||||||
|  | - [ ] I have performed a self-review of my own code | ||||||
|  | - [ ] I have added tests that prove my fix is effective or that my feature works | ||||||
|  | - [ ] I have updated the documentation accordingly | ||||||
|  | - [ ] My changes generate no new warnings | ||||||
|  | - [ ] All existing tests are passing | ||||||
|  |  | ||||||
|  | ## Additional Notes | ||||||
|  | <!-- Any additional information that might be helpful for reviewers --> | ||||||
							
								
								
									
										174
									
								
								CONTRIBUTING.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										174
									
								
								CONTRIBUTING.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,174 @@ | |||||||
|  | # Contributing to Deka DOM Elements | ||||||
|  |  | ||||||
|  | Thank you for your interest in contributing to Deka DOM Elements (dd<el> or DDE)! This document provides guidelines and | ||||||
|  | instructions for contributing to the project. | ||||||
|  |  | ||||||
|  | ## Table of Contents | ||||||
|  |  | ||||||
|  | - [Code of Conduct](#code-of-conduct) | ||||||
|  | - [Getting Started](#getting-started) | ||||||
|  | - [Development Workflow](#development-workflow) | ||||||
|  | - [Commit Guidelines](#commit-guidelines) | ||||||
|  | - [Pull Request Process](#pull-request-process) | ||||||
|  | - [Issue Guidelines](#issue-guidelines) | ||||||
|  | - [Coding Standards](#coding-standards) | ||||||
|  | - [Testing](#testing) | ||||||
|  | - [Documentation](#documentation) | ||||||
|  |  | ||||||
|  | ## Code of Conduct | ||||||
|  |  | ||||||
|  | Please be respectful and inclusive in your interactions with other contributors. We aim to foster a welcoming community | ||||||
|  | where everyone feels comfortable participating. | ||||||
|  |  | ||||||
|  | ## Getting Started | ||||||
|  |  | ||||||
|  | 1. **Fork the repository**: | ||||||
|  | 	- Click the "Fork" button on the GitHub repository | ||||||
|  |  | ||||||
|  | 2. **Clone your fork**: | ||||||
|  | 	```bash | ||||||
|  | 	git clone https://github.com/YOUR-USERNAME/deka-dom-el.git | ||||||
|  | 	cd deka-dom-el | ||||||
|  | 	``` | ||||||
|  |  | ||||||
|  | 3. **Set up the development environment**: | ||||||
|  | 	```bash | ||||||
|  | 	npm ci | ||||||
|  | 	``` | ||||||
|  |  | ||||||
|  | 4. **Add the upstream repository**: | ||||||
|  | 	```bash | ||||||
|  | 	git remote add upstream https://github.com/jaandrle/deka-dom-el.git | ||||||
|  | 	``` | ||||||
|  |  | ||||||
|  | ## Development Workflow | ||||||
|  |  | ||||||
|  | 1. **Create a new branch**: | ||||||
|  | 	```bash | ||||||
|  | 	git checkout -b your-feature-branch | ||||||
|  | 	``` | ||||||
|  | 	Use descriptive branch names that reflect the changes you're making. | ||||||
|  |  | ||||||
|  | 2. **Make your changes**: | ||||||
|  | 	- Write clean, modular code | ||||||
|  | 	- Follow the project's coding standards (see [Coding Standards](#coding-standards)) | ||||||
|  | 	- Include relevant tests for your changes | ||||||
|  |  | ||||||
|  | 3. ~**Run tests**:~ | ||||||
|  | 	```bash | ||||||
|  | 	#npm test | ||||||
|  | 	``` | ||||||
|  |  | ||||||
|  | 4. **Build the project**: | ||||||
|  | 	```bash | ||||||
|  | 	npm run build | ||||||
|  | 	#or | ||||||
|  | 	bs/build.js | ||||||
|  | 	``` | ||||||
|  |  | ||||||
|  | 5. **Preview documentation changes** (if applicable): | ||||||
|  | 	```bash | ||||||
|  | 	npm run docs | ||||||
|  | 	#or | ||||||
|  | 	bs/docs.js | ||||||
|  | 	``` | ||||||
|  |  | ||||||
|  | …see [BS folder](./bs/README.md) for more info. | ||||||
|  |  | ||||||
|  | ## Commit Guidelines | ||||||
|  |  | ||||||
|  | We use | ||||||
|  | [](https://robinpokorny.github.io/git3moji/) <!-- editorconfig-checker-disable-line --> | ||||||
|  | for commit messages. This helps keep the commit history clear and consistent. | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  | :emoji: Short summary of the change | ||||||
|  | ``` | ||||||
|  | …for example: | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  | :bug: Fix signal update not triggering on nested properties | ||||||
|  | :zap: Improve event delegation performance | ||||||
|  | :abc: Add documentation for custom elements | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Pull Request Process | ||||||
|  |  | ||||||
|  | 1. **Push your changes**: | ||||||
|  | 	```bash | ||||||
|  | 	git push origin your-feature-branch | ||||||
|  | 	``` | ||||||
|  |  | ||||||
|  | 2. **Open a Pull Request**: | ||||||
|  | 	- Go to the repository on GitHub | ||||||
|  | 	- Click "New Pull Request" | ||||||
|  | 	- Select your branch | ||||||
|  | 	- Provide a clear description of your changes | ||||||
|  |  | ||||||
|  | 3. **PR Guidelines**: | ||||||
|  | 	- Use a clear, descriptive title with the appropriate git3moji | ||||||
|  | 	- Reference any related issues | ||||||
|  | 	- Explain what the changes do and why they are needed | ||||||
|  | 	- List any dependencies that are required for the change | ||||||
|  | 	- Include screenshots or examples if applicable | ||||||
|  |  | ||||||
|  | 4. **Code Review**: | ||||||
|  | 	- Address any feedback from reviewers | ||||||
|  | 	- Make necessary changes and push to your branch | ||||||
|  | 	- The PR will be updated automatically | ||||||
|  |  | ||||||
|  | 5. **Merge**: | ||||||
|  | 	- Once approved, a maintainer will merge your PR | ||||||
|  | 	- The main branch is protected, so you cannot push directly to it | ||||||
|  |  | ||||||
|  | ## Issue Guidelines | ||||||
|  |  | ||||||
|  | When creating an issue, please use the appropriate template and include as much information as possible: | ||||||
|  |  | ||||||
|  | ### Bug Reports | ||||||
|  |  | ||||||
|  | - Use the `:bug:` emoji in the title | ||||||
|  | - Clearly describe the issue | ||||||
|  | - Include steps to reproduce | ||||||
|  | - Mention your environment (browser, OS, etc.) | ||||||
|  | - Add screenshots if applicable | ||||||
|  |  | ||||||
|  | ### Feature Requests | ||||||
|  |  | ||||||
|  | - Use the `:zap:` emoji in the title | ||||||
|  | - Describe the feature clearly | ||||||
|  | - Explain why it would be valuable | ||||||
|  | - Include examples or mockups if possible | ||||||
|  |  | ||||||
|  | ### Documentation Improvements | ||||||
|  |  | ||||||
|  | - Use the `:abc:` emoji in the title | ||||||
|  | - Identify what documentation needs improvement | ||||||
|  | - Suggest specific changes or additions | ||||||
|  |  | ||||||
|  | ## Coding Standards | ||||||
|  |  | ||||||
|  | - Follow the existing code style in the project | ||||||
|  | - Use meaningful variable and function names | ||||||
|  | - Keep functions small and focused | ||||||
|  | - Add comments for complex logic | ||||||
|  | - Use TypeScript types appropriately | ||||||
|  |  | ||||||
|  | <!-- | ||||||
|  | ## Testing | ||||||
|  |  | ||||||
|  | - Add tests for new features | ||||||
|  | - Update tests for modified code | ||||||
|  | - Ensure all tests pass before submitting a PR | ||||||
|  | --> | ||||||
|  |  | ||||||
|  | ## Documentation | ||||||
|  |  | ||||||
|  | - Update the documentation when you add or modify features | ||||||
|  | - Document both API usage and underlying concepts | ||||||
|  | - Use clear, concise language | ||||||
|  | - Include examples where appropriate | ||||||
|  |  | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | Thank you for contributing to Deka DOM Elements! Your efforts help make the project better for everyone. | ||||||
| @@ -1,6 +1,7 @@ | |||||||
| **WIP** (the experimentation phase) | **WIP** (the experimentation phase) | ||||||
| | [source code on GitHub](https://github.com/jaandrle/deka-dom-el) | | [source code on GitHub](https://github.com/jaandrle/deka-dom-el) | ||||||
| | [*mirrored* on Gitea](https://gitea.jaandrle.cz/jaandrle/deka-dom-el) | | [*mirrored* on Gitea](https://gitea.jaandrle.cz/jaandrle/deka-dom-el) | ||||||
|  | | [](https://robinpokorny.github.io/git3moji/) <!-- editorconfig-checker-disable-line --> | ||||||
|  |  | ||||||
| <p align="center"> | <p align="center"> | ||||||
| 	<img src="docs/assets/logo.svg" alt="Deka DOM Elements Logo" width="180" height="180"> | 	<img src="docs/assets/logo.svg" alt="Deka DOM Elements Logo" width="180" height="180"> | ||||||
| @@ -127,6 +128,11 @@ Signals are the reactive backbone of Deka DOM Elements: | |||||||
| - [TC39 Signals Proposal](https://github.com/tc39/proposal-signals) (future standard) | - [TC39 Signals Proposal](https://github.com/tc39/proposal-signals) (future standard) | ||||||
| - [Observer pattern](https://en.wikipedia.org/wiki/Observer_pattern) (underlying concept) | - [Observer pattern](https://en.wikipedia.org/wiki/Observer_pattern) (underlying concept) | ||||||
|  |  | ||||||
|  | ## Contributing | ||||||
|  |  | ||||||
|  | We welcome contributions from the community! Please see our [Contributing Guide](CONTRIBUTING.md) for details on how to | ||||||
|  | get started, coding standards, commit guidelines, and the pull request process. | ||||||
|  |  | ||||||
| ## Inspiration and Alternatives | ## Inspiration and Alternatives | ||||||
|  |  | ||||||
| - [vanjs-org/van](https://github.com/vanjs-org/van) — World's smallest reactive UI framework | - [vanjs-org/van](https://github.com/vanjs-org/van) — World's smallest reactive UI framework | ||||||
|   | |||||||
| @@ -2,15 +2,18 @@ | |||||||
| This project uses [jaandrle/bs: The simplest possible build system using executable/bash scripts]( | This project uses [jaandrle/bs: The simplest possible build system using executable/bash scripts]( | ||||||
| https://github.com/jaandrle/bs). | https://github.com/jaandrle/bs). | ||||||
|  |  | ||||||
| #### bs/build.js [--minify|--help] | #### bs/build.js [main|signals] [--no-types|--help] | ||||||
| Generates alternative versions of the project (other than native ESM code). | Generates alternative versions of the project (other than native ESM code). | ||||||
| Also generates typescript definitions. | Also generates typescript definitions. | ||||||
|  |  | ||||||
| #### bs/docs.js | #### bs/docs.js | ||||||
| Generates documentation, from `docs/`. Uses “SSR” technique, using deka-dom-el itself. | Generates documentation, from `docs/`. Uses “SSR” technique, using deka-dom-el itself. | ||||||
|  |  | ||||||
|  | For running use `npx serve dist/docs`. | ||||||
|  |  | ||||||
| #### bs/lint.sh | #### bs/lint.sh | ||||||
| Lints size of the project, jshint. See configs: | Lints size of the project, jshint. See configs: | ||||||
|  |  | ||||||
| - `package.json`: key `size-limit` | - `package.json`: key `size-limit` | ||||||
| - `package.json`: key `jshintConfig` | - `package.json`: key `jshintConfig` | ||||||
|  | - `.editorconfig` | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ export function mnemonic(){ | |||||||
| 		), | 		), | ||||||
| 		el("li").append( | 		el("li").append( | ||||||
| 			el("code", "el(<tag-name>, <primitive>)[.append(...)]: <element-from-tag-name>"), | 			el("code", "el(<tag-name>, <primitive>)[.append(...)]: <element-from-tag-name>"), | ||||||
| 			" — simple element containing only text", | 			" — simple element containing only text (accepts string, number or signal)", | ||||||
| 		), | 		), | ||||||
| 		el("li").append( | 		el("li").append( | ||||||
| 			el("code", "el(<tag-name>, <object>)[.append(...)]: <element-from-tag-name>"), | 			el("code", "el(<tag-name>, <object>)[.append(...)]: <element-from-tag-name>"), | ||||||
| @@ -26,6 +26,6 @@ export function mnemonic(){ | |||||||
| 		el("li").append( | 		el("li").append( | ||||||
| 			el("code", "elNS(<namespace>)(<as-el-see-above>)[.append(...)]: <element-based-on-arguments>"), | 			el("code", "elNS(<namespace>)(<as-el-see-above>)[.append(...)]: <element-based-on-arguments>"), | ||||||
| 			" — typically SVG elements", | 			" — typically SVG elements", | ||||||
| 		) | 		), | ||||||
| 	); | 	); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -29,7 +29,7 @@ export function mnemonic(){ | |||||||
| 		el("li").append( | 		el("li").append( | ||||||
| 			el("code", "S.clear(...<signals>)"), | 			el("code", "S.clear(...<signals>)"), | ||||||
| 			" — off and clear signals (most of the time it is not needed as reactive ", | 			" — off and clear signals (most of the time it is not needed as reactive ", | ||||||
| 			"attributes and elements are cleared automatically)", | 			"attributes and elements are handled automatically)", | ||||||
| 		), | 		), | ||||||
| 	); | 	); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -82,7 +82,7 @@ export function page({ pkg, info }){ | |||||||
|  |  | ||||||
| 		el("p").append(T` | 		el("p").append(T` | ||||||
| 			By separating these concerns, your code becomes more modular, testable, and easier to maintain. This | 			By separating these concerns, your code becomes more modular, testable, and easier to maintain. This | ||||||
| 			approach ${el("strong", "is not")} something new and/or special to dd<el>. It’s based on ${el("a", { | 			approach ${el("strong", "is not something new and/or special to dd<el>")}. It’s based on ${el("a", { | ||||||
| 				textContent: "MVC", ...references.w_mvc })} (${el("a", { textContent: "MVVM", ...references.w_mvv })}), | 				textContent: "MVC", ...references.w_mvc })} (${el("a", { textContent: "MVVM", ...references.w_mvv })}), | ||||||
| 			but is there presented in simpler form. | 			but is there presented in simpler form. | ||||||
| 		`), | 		`), | ||||||
| @@ -154,6 +154,10 @@ export function page({ pkg, info }){ | |||||||
| 				Interactive demos with server-side pre-rendering`), | 				Interactive demos with server-side pre-rendering`), | ||||||
| 			el("li").append(T`${el("a", { href: "p13-appendix.html" }).append(el("strong", "Appendix & Summary"))} — | 			el("li").append(T`${el("a", { href: "p13-appendix.html" }).append(el("strong", "Appendix & Summary"))} — | ||||||
| 				Comprehensive reference and best practices`), | 				Comprehensive reference and best practices`), | ||||||
|  | 			el("li").append(T`${el("a", { href: "p14-converter.html" }).append(el("strong", "HTML Converter"))} — | ||||||
|  | 				Convert HTML to dd<el> JavaScript code`), | ||||||
|  | 			el("li").append(T`${el("a", { href: "p15-examples.html" }).append(el("strong", "Examples Gallery"))} — | ||||||
|  | 				Real-world application examples and case studies`), | ||||||
| 		), | 		), | ||||||
| 		el("p").append(T` | 		el("p").append(T` | ||||||
| 			Each section builds on the previous ones, so we recommend following them in order. | 			Each section builds on the previous ones, so we recommend following them in order. | ||||||
|   | |||||||
| @@ -208,6 +208,6 @@ export function page({ pkg, info }){ | |||||||
| 			`), | 			`), | ||||||
| 		), | 		), | ||||||
|  |  | ||||||
| 		el(mnemonic) | 		el(mnemonic), | ||||||
| 	); | 	); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -136,7 +136,7 @@ export function page({ pkg, info }){ | |||||||
| 				el("li", t`Set up lifecycle behaviors`), | 				el("li", t`Set up lifecycle behaviors`), | ||||||
| 				el("li", t`Integrate third-party libraries`), | 				el("li", t`Integrate third-party libraries`), | ||||||
| 				el("li", t`Create reusable element behaviors`), | 				el("li", t`Create reusable element behaviors`), | ||||||
| 				el("li", t`Capture element references`) | 				el("li", t`Capture element references`), // TODO: add example? | ||||||
| 			) | 			) | ||||||
| 		), | 		), | ||||||
| 		el("p").append(T` | 		el("p").append(T` | ||||||
|   | |||||||
| @@ -277,7 +277,72 @@ export function page({ pkg, info }){ | |||||||
| 			`), | 			`), | ||||||
| 			el("li").append(T` | 			el("li").append(T` | ||||||
| 				${el("strong", "Avoid infinite loops")}: Be careful when one signal updates another in a subscription | 				${el("strong", "Avoid infinite loops")}: Be careful when one signal updates another in a subscription | ||||||
| 			`) | 			`), | ||||||
|  | 		), | ||||||
|  | 		el("p").append(T` | ||||||
|  | 			While signals provide powerful reactivity for complex UI interactions, they’re not always necessary. | ||||||
|  | 			A good approach is to started with variables/constants and when necessary, convert them to signals. | ||||||
|  | 		`), | ||||||
|  |  | ||||||
|  | 		el("div", { className: "tabs" }).append( | ||||||
|  | 			el("div", { className: "tab", dataTab: "events" }).append( | ||||||
|  | 				el("h4", t`We can process form events without signals`), | ||||||
|  | 				el("p", t`This can be used when the form data doesn’t need to be reactive and we just waiting for | ||||||
|  | 					results.`), | ||||||
|  | 				el(code, { page_id, content: ` | ||||||
|  | 					const onFormSubmit = on("submit", e => { | ||||||
|  | 						e.preventDefault(); | ||||||
|  | 						const formData = new FormData(e.currentTarget); | ||||||
|  | 						// this can be sent to a server | ||||||
|  | 						// or processed locally | ||||||
|  | 						// e.g.: console.log(Object.fromEntries(formData)) | ||||||
|  | 					}); | ||||||
|  | 					// … | ||||||
|  | 					return el("form", null, onFormSubmit).append( | ||||||
|  | 						// … | ||||||
|  | 					); | ||||||
|  | 				` }) | ||||||
|  | 			), | ||||||
|  |  | ||||||
|  | 			el("div", { className: "tab", dataTab: "variables" }).append( | ||||||
|  | 				el("h4", t`We can use variables without signals`), | ||||||
|  | 				el("p", t`We use this when we dont’t need to reflect changes in the elsewhere (UI).`), | ||||||
|  | 				el(code, { page_id, content: ` | ||||||
|  | 					let canSubmit = false; | ||||||
|  |  | ||||||
|  | 					const onFormSubmit = on("submit", e => { | ||||||
|  | 						e.preventDefault(); | ||||||
|  | 						if(!canSubmit) return; // some message | ||||||
|  | 						// … | ||||||
|  | 					}); | ||||||
|  | 					const onAllowSubmit = on("click", e => { | ||||||
|  | 						canSubmit = true; | ||||||
|  | 					}); | ||||||
|  | 				`}), | ||||||
|  | 			), | ||||||
|  |  | ||||||
|  | 			el("div", { className: "tab", dataTab: "state" }).append( | ||||||
|  | 				el("h4", t`Using signals`), | ||||||
|  | 				el("p", t`We use this when we need to reflect changes for example in the UI (e.g. enable/disable | ||||||
|  | 					buttons).`), | ||||||
|  | 				el(code, { page_id, content: ` | ||||||
|  | 					const canSubmit = S(false); | ||||||
|  |  | ||||||
|  | 					const onFormSubmit = on("submit", e => { | ||||||
|  | 						e.preventDefault(); | ||||||
|  | 						// … | ||||||
|  | 					}); | ||||||
|  | 					const onAllowSubmit = on("click", e => { | ||||||
|  | 						canSubmit.set(true); | ||||||
|  | 					}); | ||||||
|  |  | ||||||
|  | 					return el("form", null, onFormSubmit).append( | ||||||
|  | 						// ... | ||||||
|  | 						el("button", { textContent: "Allow Submit", type: "button" }, onAllowSubmit), | ||||||
|  | 						el("button", { disabled: S(()=> !canSubmit), textContent: "Submit" }) | ||||||
|  | 					); | ||||||
|  | 				`}), | ||||||
|  | 			), | ||||||
| 		), | 		), | ||||||
|  |  | ||||||
| 		el("div", { className: "troubleshooting" }).append( | 		el("div", { className: "troubleshooting" }).append( | ||||||
| @@ -298,6 +363,6 @@ export function page({ pkg, info }){ | |||||||
| 			) | 			) | ||||||
| 		), | 		), | ||||||
|  |  | ||||||
| 		el(mnemonic) | 		el(mnemonic), | ||||||
| 	); | 	); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -55,7 +55,7 @@ export function page({ pkg, info }){ | |||||||
| 				el(MyComponent); | 				el(MyComponent); | ||||||
|  |  | ||||||
| 				function MyComponent() { | 				function MyComponent() { | ||||||
| 					// 2. access the host element | 					// 2. access the host element (or other scope related values) | ||||||
| 					const { host } = scope; | 					const { host } = scope; | ||||||
|  |  | ||||||
| 					// 3. Add behavior to host | 					// 3. Add behavior to host | ||||||
|   | |||||||
| @@ -80,7 +80,7 @@ export function page({ pkg, info }){ | |||||||
| 			el("li", t`listeners: A Set of functions called when the signal value changes`), | 			el("li", t`listeners: A Set of functions called when the signal value changes`), | ||||||
| 			el("li", t`actions: Custom actions that can be performed on the signal`), | 			el("li", t`actions: Custom actions that can be performed on the signal`), | ||||||
| 			el("li", t`onclear: Functions to run when the signal is cleared`), | 			el("li", t`onclear: Functions to run when the signal is cleared`), | ||||||
| 			el("li", t`host: Reference to the host element/scope`), | 			el("li", t`host: Reference to the host element/scope in which the signal was created`), | ||||||
| 			el("li", t`defined: Stack trace information for debugging`), | 			el("li", t`defined: Stack trace information for debugging`), | ||||||
| 			el("li", t`readonly: Boolean flag indicating if the signal is read-only`) | 			el("li", t`readonly: Boolean flag indicating if the signal is read-only`) | ||||||
| 		), | 		), | ||||||
| @@ -114,7 +114,13 @@ export function page({ pkg, info }){ | |||||||
| 		el("ul").append( | 		el("ul").append( | ||||||
| 			el("li", t`That you’re using signal.set() to update the value, not modifying objects/arrays directly`), | 			el("li", t`That you’re using signal.set() to update the value, not modifying objects/arrays directly`), | ||||||
| 			el("li", t`For mutable objects, ensure you’re using actions or making proper copies before updating`), | 			el("li", t`For mutable objects, ensure you’re using actions or making proper copies before updating`), | ||||||
| 			el("li", t`That the signal is actually connected to the DOM element (check your S.el or attribute binding code)`) | 			el("li", t`That the signal is actually connected to the DOM element (check your S.el or attribute binding | ||||||
|  | 				code)`), | ||||||
|  | 			el("li").append(T` | ||||||
|  | 				That you’re passing signal corecctly (without using ${el("code", "*.get()")}) and for ${el("code", | ||||||
|  | 				"S.el")} that you passing (derived) signals not a function (use ${el("code", | ||||||
|  | 				"S.el(S(()=> count.get() % 2), odd=> …)")}). | ||||||
|  | 			`), | ||||||
| 		), | 		), | ||||||
| 		el(code, { src: fileURL("./components/examples/debugging/mutations.js"), page_id }), | 		el(code, { src: fileURL("./components/examples/debugging/mutations.js"), page_id }), | ||||||
|  |  | ||||||
|   | |||||||
| @@ -129,75 +129,6 @@ export function page({ pkg, info }){ | |||||||
| 			`) | 			`) | ||||||
| 		), | 		), | ||||||
|  |  | ||||||
| 		el("h4", t`Using Signals Appropriately`), |  | ||||||
| 		el("p").append(T` |  | ||||||
| 			While signals provide powerful reactivity for complex UI interactions, they’re not always necessary. |  | ||||||
| 		`), |  | ||||||
|  |  | ||||||
| 		el("div", { className: "tabs" }).append( |  | ||||||
| 			el("div", { className: "tab", dataTab: "events" }).append( |  | ||||||
| 				el("h4", t`We can process form events without signals`), |  | ||||||
| 				el("p", t`This can be used when the form data doesn’t need to be reactive and we just waiting for |  | ||||||
| 					results.`), |  | ||||||
| 				el(code, { page_id, content: ` |  | ||||||
| 					const onFormSubmit = on("submit", e => { |  | ||||||
| 						e.preventDefault(); |  | ||||||
| 						const formData = new FormData(e.currentTarget); |  | ||||||
| 						// this can be sent to a server |  | ||||||
| 						// or processed locally |  | ||||||
| 						// e.g.: console.log(Object.fromEntries(formData)) |  | ||||||
| 					}); |  | ||||||
| 					// … |  | ||||||
| 					return el("form", null, onFormSubmit).append( |  | ||||||
| 						// … |  | ||||||
| 					); |  | ||||||
| 				` }) |  | ||||||
| 			), |  | ||||||
|  |  | ||||||
| 			el("div", { className: "tab", dataTab: "variables" }).append( |  | ||||||
| 				el("h4", t`We can use variables without signals`), |  | ||||||
| 				el("p", t`We use this when we dont’t need to reflect changes in the elsewhere (UI).`), |  | ||||||
| 				el(code, { page_id, content: ` |  | ||||||
| 					let canSubmit = false; |  | ||||||
|  |  | ||||||
| 					const onFormSubmit = on("submit", e => { |  | ||||||
| 						e.preventDefault(); |  | ||||||
| 						if(!canSubmit) return; // some message |  | ||||||
| 						// … |  | ||||||
| 					}); |  | ||||||
| 					const onAllowSubmit = on("click", e => { |  | ||||||
| 						canSubmit = true; |  | ||||||
| 					}); |  | ||||||
| 				`}), |  | ||||||
| 			), |  | ||||||
|  |  | ||||||
| 			el("div", { className: "tab", dataTab: "state" }).append( |  | ||||||
| 				el("h4", t`Using signals`), |  | ||||||
| 				el("p", t`We use this when we need to reflect changes for example in the UI (e.g. enable/disable |  | ||||||
| 					buttons).`), |  | ||||||
| 				el(code, { page_id, content: ` |  | ||||||
| 					const canSubmit = S(false); |  | ||||||
|  |  | ||||||
| 					const onFormSubmit = on("submit", e => { |  | ||||||
| 						e.preventDefault(); |  | ||||||
| 						// … |  | ||||||
| 					}); |  | ||||||
| 					const onAllowSubmit = on("click", e => { |  | ||||||
| 						canSubmit.set(true); |  | ||||||
| 					}); |  | ||||||
|  |  | ||||||
| 					return el("form", null, onFormSubmit).append( |  | ||||||
| 						// ... |  | ||||||
| 						el("button", { textContent: "Allow Submit", type: "button" }, onAllowSubmit), |  | ||||||
| 						el("button", { disabled: S(()=> !canSubmit), textContent: "Submit" }) |  | ||||||
| 					); |  | ||||||
| 				`}), |  | ||||||
| 			), |  | ||||||
| 			el("p").append(T` |  | ||||||
| 				A good approach is to started with variables/constants and when necessary, convert them to signals. |  | ||||||
| 			`), |  | ||||||
| 		), |  | ||||||
|  |  | ||||||
| 		el("h4", t`Migrating from Traditional Approaches`), | 		el("h4", t`Migrating from Traditional Approaches`), | ||||||
| 		el("p").append(T` | 		el("p").append(T` | ||||||
| 			When migrating from traditional DOM manipulation or other frameworks to dd<el>: | 			When migrating from traditional DOM manipulation or other frameworks to dd<el>: | ||||||
| @@ -394,46 +325,46 @@ export function page({ pkg, info }){ | |||||||
| 				el("tr").append( | 				el("tr").append( | ||||||
| 					el("th", "Feature"), | 					el("th", "Feature"), | ||||||
| 					el("th", "dd<el>"), | 					el("th", "dd<el>"), | ||||||
| 					el("th", "React"), | 					el("th", "VanJS"), | ||||||
| 					el("th", "Vue"), | 					el("th", "Solid"), | ||||||
| 					el("th", "Svelte") | 					el("th", "Alpine") | ||||||
| 				) | 				) | ||||||
| 			), | 			), | ||||||
| 			el("tbody").append( | 			el("tbody").append( | ||||||
| 				el("tr").append( | 				el("tr").append( | ||||||
| 					el("td", "No Build Step Required"), | 					el("td", "No Build Step Required"), | ||||||
| 					el("td", "✅"), | 					el("td", "✅"), | ||||||
|  | 					el("td", "✅"), | ||||||
| 					el("td", "⚠️ JSX needs transpilation"), | 					el("td", "⚠️ JSX needs transpilation"), | ||||||
| 					el("td", "⚠️ SFC needs compilation"), | 					el("td", "✅") | ||||||
| 					el("td", "❌ Requires compilation") |  | ||||||
| 				), | 				), | ||||||
| 				el("tr").append( | 				el("tr").append( | ||||||
| 					el("td", "Bundle Size (minimal)"), | 					el("td", "Bundle Size (minified)"), | ||||||
| 					el("td", "~10-15kb"), | 					el("td", "~14kb"), | ||||||
| 					el("td", "~40kb+"), | 					el("td", "~3kb"), | ||||||
| 					el("td", "~33kb+"), | 					el("td", "~20kb"), | ||||||
| 					el("td", "Minimal runtime") | 					el("td", "~43kb") | ||||||
| 				), | 				), | ||||||
| 				el("tr").append( | 				el("tr").append( | ||||||
| 					el("td", "Reactivity Model"), | 					el("td", "Reactivity Model"), | ||||||
| 					el("td", "Signal-based"), | 					el("td", "Signal-based"), | ||||||
| 					el("td", "Virtual DOM diffing"), | 					el("td", "Signal-based (basics only)"), | ||||||
| 					el("td", "Proxy-based"), | 					el("td", "Signal-based"), | ||||||
| 					el("td", "Compile-time reactivity") | 					el("td", "MVVM + Proxy") | ||||||
| 				), | 				), | ||||||
| 				el("tr").append( | 				el("tr").append( | ||||||
| 					el("td", "DOM Interface"), | 					el("td", "DOM Interface"), | ||||||
| 					el("td", "Direct DOM API"), | 					el("td", "Direct DOM API"), | ||||||
| 					el("td", "Virtual DOM"), | 					el("td", "Direct DOM API"), | ||||||
| 					el("td", "Virtual DOM"), | 					el("td", "Compiled DOM updates"), | ||||||
| 					el("td", "Compiled DOM updates") | 					el("td", "Directive-based") | ||||||
| 				), | 				), | ||||||
| 				el("tr").append( | 				el("tr").append( | ||||||
| 					el("td", "Server-Side Rendering"), | 					el("td", "Server-Side Rendering"), | ||||||
| 					el("td", "✅ Basic Support"), | 					el("td", "✅ Basic Support"), | ||||||
|  | 					el("td", "✅ Basic Support"), | ||||||
| 					el("td", "✅ Advanced"), | 					el("td", "✅ Advanced"), | ||||||
| 					el("td", "✅ Advanced"), | 					el("td", "❌") | ||||||
| 					el("td", "✅ Advanced") |  | ||||||
| 				) | 				) | ||||||
| 			) | 			) | ||||||
| 		), | 		), | ||||||
|   | |||||||
| @@ -85,7 +85,12 @@ | |||||||
| 	"modifyEsbuildConfig": { | 	"modifyEsbuildConfig": { | ||||||
| 		"platform": "browser" | 		"platform": "browser" | ||||||
| 	}, | 	}, | ||||||
| 	"scripts": {}, | 	"scripts": { | ||||||
|  | 		"test": "echo \"Error: no tests yet\"", | ||||||
|  | 		"build": "bs/build.js", | ||||||
|  | 		"lint": "bs/lint.sh", | ||||||
|  | 		"docs": "bs/docs.sh" | ||||||
|  | 	}, | ||||||
| 	"keywords": [ | 	"keywords": [ | ||||||
| 		"dom", | 		"dom", | ||||||
| 		"javascript", | 		"javascript", | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user