@robert.tools/molecule-button-link 0.0.0-stage → 1.0.1
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 +21 -0
- package/README.md +81 -2
- package/dist/index.d.ts +0 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +68 -5
- package/src/index.css +0 -0
- package/src/index.njk +37 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Robert Willemelis
|
|
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
CHANGED
|
@@ -1,3 +1,82 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 🗂️ @robert.tools/molecule-button-link
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A Component to provide a wrapper between button and link.
|
|
4
|
+
|
|
5
|
+
## 📜 Usage
|
|
6
|
+
|
|
7
|
+
### 🟢 Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @robert.tools/molecule-button-link
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
#### 🔐 dependencies
|
|
14
|
+
|
|
15
|
+
- [Component: molecule-link](https://github.com/robert-tools/molecule-link)
|
|
16
|
+
- [Component: atom-button](https://github.com/robert-tools/atom-button)
|
|
17
|
+
- [Filter: safeParam](https://github.com/robert-tools/eleventy-filter-safe-param)
|
|
18
|
+
- [Filter: svg](https://github.com/robert-tools/eleventy-filter-svg)
|
|
19
|
+
- [Filter: merge](https://github.com/robert-tools/eleventy-filter-merge)
|
|
20
|
+
|
|
21
|
+
### 📝 Sample usage
|
|
22
|
+
|
|
23
|
+
#### prerequisites
|
|
24
|
+
|
|
25
|
+
- define css variables
|
|
26
|
+
|
|
27
|
+
#### Template
|
|
28
|
+
|
|
29
|
+
Use the footer component as shown below:
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
{{ component("molecule/button-link", {
|
|
33
|
+
"type": "link",
|
|
34
|
+
"text": "My Button",
|
|
35
|
+
"url": "https://example.com",
|
|
36
|
+
"disabled": false
|
|
37
|
+
}) }}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
##### ⚙️ parameter
|
|
41
|
+
|
|
42
|
+
- **class**: CSS class for the link-button
|
|
43
|
+
- **class_modifier**: CSS class modifier for the link-button
|
|
44
|
+
- **url**: URL of the link-button
|
|
45
|
+
- **target**: target attribute of the link-button
|
|
46
|
+
- **disabled**: whether the link-button is disabled
|
|
47
|
+
- **text**: text of the link-button
|
|
48
|
+
- **collapseID**: ID for collapsible content
|
|
49
|
+
- **collapseShow**: whether the collapsible content is shown
|
|
50
|
+
- **type_content**: type of content within the link-button
|
|
51
|
+
- **pre_html**: HTML to be inserted before the link-button
|
|
52
|
+
- **post_html**: HTML to be inserted after the link-button
|
|
53
|
+
- **attributes**: additional attributes for the link-button
|
|
54
|
+
|
|
55
|
+
#### CSS
|
|
56
|
+
|
|
57
|
+
Use the basic styling
|
|
58
|
+
|
|
59
|
+
```css
|
|
60
|
+
@import '@robert.tools/molecule-button-link/src/index.css';
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
#### TypeScript
|
|
64
|
+
|
|
65
|
+
Include TypeScript by importing the component
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import * as MoleculeButtonLink from '@robert.tools/molecule-button-link';
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
## ⚖️ Notes
|
|
73
|
+
|
|
74
|
+
This software is hand-crafted, test-driven and assisted by AI tools. I know each
|
|
75
|
+
line of my code. ✌️
|
|
76
|
+
|
|
77
|
+
| Tool | Comment |
|
|
78
|
+
| --- | --- |
|
|
79
|
+
|  | Test-driven development with Jest |
|
|
80
|
+
|  | Part of the robert.tools ecosystem |
|
|
81
|
+
|  | Code completion |
|
|
82
|
+
|  | chatGPT research |
|
package/dist/index.d.ts
ADDED
|
File without changes
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,69 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@robert.tools/molecule-button-link",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "A Component to provide a wrapper between button and link.",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"default": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./index.njk": "./src/index.njk",
|
|
12
|
+
"./index.css": "./src/index.css"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"src/index.njk",
|
|
17
|
+
"src/index.css"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"init": "robi init",
|
|
21
|
+
"release": "robi release",
|
|
22
|
+
"status": "robi status",
|
|
23
|
+
"version": "robi version",
|
|
24
|
+
"verbose": "robi verbose",
|
|
25
|
+
"pub": "npm whoami && npm publish --access public",
|
|
26
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
27
|
+
"test": "jest --coverage --runInBand --verbose --no-watchman",
|
|
28
|
+
"lint": "eslint .",
|
|
29
|
+
"check": "npm run lint && npm test && npm run build",
|
|
30
|
+
"prepublishOnly": "npm run check"
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/robert-tools/molecule-button-link.git"
|
|
35
|
+
},
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/robert-tools/molecule-button-link/issues"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://github.com/robert-tools/molecule-button-link#readme",
|
|
40
|
+
"keywords": [
|
|
41
|
+
"typescript",
|
|
42
|
+
"node",
|
|
43
|
+
"molecule-button-link",
|
|
44
|
+
"robert.tools"
|
|
45
|
+
],
|
|
46
|
+
"author": "Robert Willemelis",
|
|
47
|
+
"license": "MIT",
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=22"
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public",
|
|
53
|
+
"registry": "https://registry.npmjs.org/"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@robert.tools/setup": "^1.3.0",
|
|
57
|
+
"@types/jest": "^29.5.14",
|
|
58
|
+
"@types/node": "^24.0.0",
|
|
59
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
60
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
61
|
+
"eslint": "^9.0.0",
|
|
62
|
+
"eslint-config-prettier": "^10.1.8",
|
|
63
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
64
|
+
"jest": "^29.7.0",
|
|
65
|
+
"jest-environment-jsdom": "^29.6.2",
|
|
66
|
+
"ts-jest": "^29.4.0",
|
|
67
|
+
"typescript": "^5.9.0"
|
|
68
|
+
}
|
|
69
|
+
}
|
package/src/index.css
ADDED
|
File without changes
|
package/src/index.njk
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{% set dimension = [params.width, params.height] if params.width and params.height else params.size %}
|
|
2
|
+
{% set class_svg = params.class_svg | safeParam() %}
|
|
3
|
+
{% set class_modifier = params.class_modifier | safeParam() %}
|
|
4
|
+
|
|
5
|
+
{% set pre_html = (params.image_before | replace("./assets/", "") | svg(dimension, class_svg, attributes) | safe) if params.image_before is defined else "" %}
|
|
6
|
+
{% set post_html = (params.image_after | replace("./assets/", "") | svg(dimension, class_svg, attributes) | safe) if params.image_after is defined else "" %}
|
|
7
|
+
|
|
8
|
+
{% set type = params.type | safeParam(params.type_button) %}
|
|
9
|
+
{% set text = params.text | safeParam() %}
|
|
10
|
+
{% set type_content = params.type_content | safeParam() %}
|
|
11
|
+
|
|
12
|
+
{# set component type #}
|
|
13
|
+
{% set component_name = "atom/button" if type == "button" else "molecule/link" %}
|
|
14
|
+
|
|
15
|
+
{% if params.type_content and type == "button" %}
|
|
16
|
+
{% set class_modifier = class_modifier + " btn btn-" + type_content %}
|
|
17
|
+
{% endif %}
|
|
18
|
+
|
|
19
|
+
{# set optional attributes #}
|
|
20
|
+
{% set attributes = {} %}
|
|
21
|
+
{% if params.focusable is defined %}
|
|
22
|
+
{% set attributes = attributes | merge({"focusable": params.focusable}) %}
|
|
23
|
+
{% endif %}
|
|
24
|
+
|
|
25
|
+
{% if params.aria_hidden is defined %}
|
|
26
|
+
{% set attributes = attributes | merge({"ariaHidden": params.aria_hidden}) %}
|
|
27
|
+
{% endif %}
|
|
28
|
+
|
|
29
|
+
{{
|
|
30
|
+
component(component_name, params | merge({
|
|
31
|
+
class_modifier: class_modifier,
|
|
32
|
+
type_content: type_content,
|
|
33
|
+
pre_html: pre_html,
|
|
34
|
+
post_html: post_html,
|
|
35
|
+
attributes: attributes
|
|
36
|
+
}))
|
|
37
|
+
}}
|