@supersoniks/concorde 3.0.3 → 3.0.4
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/docs/assets/index--bDsd7qW.css +1 -0
- package/docs/assets/index-3W2s1DcY.js +4040 -0
- package/docs/assets/index-B-7rKIow.js +4040 -0
- package/docs/assets/index-BJY63wEA.js +4040 -0
- package/docs/assets/index-BXaJoTcR.js +4040 -0
- package/docs/assets/index-NCT3BKv0.js +4040 -0
- package/docs/assets/index-PbOx6NxY.js +4040 -0
- package/docs/assets/index-cNBBlbBt.js +4040 -0
- package/docs/assets/index-gx6CCJoi.js +4040 -0
- package/docs/assets/index-l8XRMBvs.js +4040 -0
- package/docs/css/docs.css +0 -0
- package/docs/img/concorde-logo.svg +1 -0
- package/docs/img/concorde.png +0 -0
- package/docs/img/concorde_def.png +0 -0
- package/docs/index.html +132 -0
- package/docs/src/core/components/functional/date/date.md +290 -0
- package/docs/src/core/components/functional/fetch/fetch.md +117 -0
- package/docs/src/core/components/functional/if/if.md +16 -0
- package/docs/src/core/components/functional/list/list.md +194 -0
- package/docs/src/core/components/functional/mix/mix.md +41 -0
- package/docs/src/core/components/functional/queue/queue.md +87 -0
- package/docs/src/core/components/functional/router/router.md +112 -0
- package/docs/src/core/components/functional/sdui/default-library.json +108 -0
- package/docs/src/core/components/functional/sdui/example.json +99 -0
- package/docs/src/core/components/functional/sdui/sdui.md +356 -0
- package/docs/src/core/components/functional/states/states.md +87 -0
- package/docs/src/core/components/functional/submit/submit.md +48 -0
- package/docs/src/core/components/functional/subscriber/subscriber.md +91 -0
- package/docs/src/core/components/functional/value/value.md +35 -0
- package/docs/src/core/components/ui/alert/alert.md +121 -0
- package/docs/src/core/components/ui/badge/badge.md +102 -0
- package/docs/src/core/components/ui/button/button.md +184 -0
- package/docs/src/core/components/ui/captcha/captcha.md +12 -0
- package/docs/src/core/components/ui/card/card.md +96 -0
- package/docs/src/core/components/ui/divider/divider.md +35 -0
- package/docs/src/core/components/ui/form/checkbox/checkbox.md +96 -0
- package/docs/src/core/components/ui/form/fieldset/fieldset.md +129 -0
- package/docs/src/core/components/ui/form/form-actions/form-actions.md +77 -0
- package/docs/src/core/components/ui/form/form-layout/form-layout.md +43 -0
- package/docs/src/core/components/ui/form/input/input.md +168 -0
- package/docs/src/core/components/ui/form/input-autocomplete/input-autocomplete.md +130 -0
- package/docs/src/core/components/ui/form/radio/radio.md +86 -0
- package/docs/src/core/components/ui/form/select/select.md +99 -0
- package/docs/src/core/components/ui/form/textarea/textarea.md +66 -0
- package/docs/src/core/components/ui/group/group.md +75 -0
- package/docs/src/core/components/ui/icon/icon.md +125 -0
- package/docs/src/core/components/ui/icon/icons.json +1 -0
- package/docs/src/core/components/ui/image/image.md +107 -0
- package/docs/src/core/components/ui/link/link.md +43 -0
- package/docs/src/core/components/ui/loader/loader.md +37 -0
- package/docs/src/core/components/ui/menu/menu.md +288 -0
- package/docs/src/core/components/ui/modal/modal.md +123 -0
- package/docs/src/core/components/ui/pop/pop.md +79 -0
- package/docs/src/core/components/ui/progress/progress.md +65 -0
- package/docs/src/core/components/ui/table/table.md +467 -0
- package/docs/src/core/components/ui/tooltip/tooltip.md +37 -0
- package/docs/src/docs/_core-concept/overview.md +57 -0
- package/docs/src/docs/_core-concept/subscriber.md +76 -0
- package/docs/src/docs/_getting-started/concorde-outside.md +141 -0
- package/docs/src/docs/_getting-started/create-a-component.md +137 -0
- package/docs/src/docs/_getting-started/pubsub.md +150 -0
- package/docs/src/docs/_getting-started/start.md +37 -0
- package/docs/src/docs/_getting-started/theming.md +91 -0
- package/docs/src/docs/search/docs-search.json +3737 -0
- package/docs/src/tag-list.json +1 -0
- package/docs/src/tsconfig.json +113 -0
- package/docs/svg/regular/plane.svg +1 -0
- package/docs/svg/solid/plane.svg +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# installation
|
|
2
|
+
|
|
3
|
+
## Starter
|
|
4
|
+
|
|
5
|
+
The easiest way to use Concorde is by using the Concorde starter.
|
|
6
|
+
|
|
7
|
+
The following command creates a new Vite project in TypeScript mode with Tailwind and an example component to get started.
|
|
8
|
+
|
|
9
|
+
<sonic-code language="shell">
|
|
10
|
+
<template>
|
|
11
|
+
npx @supersoniks/create-concorde-ts-starter "project_name"
|
|
12
|
+
</template>
|
|
13
|
+
</sonic-code>
|
|
14
|
+
|
|
15
|
+
For a more manual configuration, you can refer to the following sections. <br/>
|
|
16
|
+
However, the Tailwind configuration is not mentioned at the moment.
|
|
17
|
+
|
|
18
|
+
## Brand New Vite Project
|
|
19
|
+
|
|
20
|
+
### Creating the Project
|
|
21
|
+
|
|
22
|
+
<sonic-code language="shell">
|
|
23
|
+
<template>
|
|
24
|
+
# Pure JavaScript project
|
|
25
|
+
yarn create vite --template vanilla-js
|
|
26
|
+
# TypeScript project (it is recommended to use this approach, which installs Lit separately if needed, via "yarn add lit")
|
|
27
|
+
yarn create vite --template vanilla-ts
|
|
28
|
+
# TypeScript + Lit project (creating new web components, for example, to extend the fetch or subscriber mixins)
|
|
29
|
+
yarn create vite --template lit-ts
|
|
30
|
+
</template>
|
|
31
|
+
</sonic-code>
|
|
32
|
+
|
|
33
|
+
Using Lit with TypeScript requires the following configuration in the "compilerOptions" section of the `tsconfig.json` file:
|
|
34
|
+
|
|
35
|
+
<sonic-code language="json">
|
|
36
|
+
<template>
|
|
37
|
+
"experimentalDecorators": true,
|
|
38
|
+
"useDefineForClassFields": false
|
|
39
|
+
</template>
|
|
40
|
+
</sonic-code>
|
|
41
|
+
|
|
42
|
+
### Installing Concorde
|
|
43
|
+
|
|
44
|
+
Navigate to the project folder created and perform the installation:
|
|
45
|
+
|
|
46
|
+
<sonic-code language="shell">
|
|
47
|
+
<template>
|
|
48
|
+
yarn add @supersoniks/concorde
|
|
49
|
+
</template>
|
|
50
|
+
</sonic-code>
|
|
51
|
+
|
|
52
|
+
### Development / Build
|
|
53
|
+
|
|
54
|
+
<sonic-code language="shell">
|
|
55
|
+
<template>
|
|
56
|
+
# Development (you can add `--host` after the command chain in package.json's dev script instead of typing it each time as shown below)
|
|
57
|
+
yarn dev --host
|
|
58
|
+
# Build
|
|
59
|
+
yarn build
|
|
60
|
+
</template>
|
|
61
|
+
</sonic-code>
|
|
62
|
+
|
|
63
|
+
## Shortcut Imports
|
|
64
|
+
|
|
65
|
+
Shortcut imports work by default in JavaScript, but in TypeScript, they are activated by choice as they inject data into *tsconfig.json*. Here is the command:
|
|
66
|
+
|
|
67
|
+
<sonic-code language="shell">
|
|
68
|
+
<template>
|
|
69
|
+
npx concorde enable-short-paths
|
|
70
|
+
</template>
|
|
71
|
+
</sonic-code>
|
|
72
|
+
|
|
73
|
+
Shortcut imports replace the actual paths with aliases as follows:
|
|
74
|
+
|
|
75
|
+
* `@supersoniks/concorde/core/components/functional_or_ui/component/component` becomes `@supersoniks/concorde/functional_or_ui/component`
|
|
76
|
+
* `@supersoniks/concorde/core/mixins_or_utils/class_name` becomes `@supersoniks/concorde/mixins_or_utils/class_name`
|
|
77
|
+
|
|
78
|
+
The original paths remain accessible. Shortcut imports are used for the examples later in this documentation.
|
|
79
|
+
|
|
80
|
+
## Usage
|
|
81
|
+
|
|
82
|
+
### Simple Integration in HTML
|
|
83
|
+
|
|
84
|
+
For example, to use a button:
|
|
85
|
+
In `main.ts` or `main.js` to be compiled:
|
|
86
|
+
|
|
87
|
+
<sonic-code language="typescript">
|
|
88
|
+
<template>
|
|
89
|
+
import "@supersoniks/concorde/ui/button";
|
|
90
|
+
</template>
|
|
91
|
+
</sonic-code>
|
|
92
|
+
|
|
93
|
+
In the HTML of a JS or TS component or in the HTML of the web page that includes the compiled JS:
|
|
94
|
+
|
|
95
|
+
<sonic-code>
|
|
96
|
+
<template>
|
|
97
|
+
<sonic-button variant="outline">My button</sonic-button>
|
|
98
|
+
</template>
|
|
99
|
+
</sonic-code>
|
|
100
|
+
|
|
101
|
+
### Using a Mixin to Create a New Lit Component
|
|
102
|
+
|
|
103
|
+
For example, create a file `my-element.ts` at the root:
|
|
104
|
+
|
|
105
|
+
<sonic-code language="typescript">
|
|
106
|
+
<template>
|
|
107
|
+
import { html, LitElement } from "lit";
|
|
108
|
+
import { customElement, property } from "lit/decorators.js";
|
|
109
|
+
import Fetcher from "@supersoniks/concorde/mixins/Fetcher";
|
|
110
|
+
import Subscriber from "@supersoniks/concorde/mixins/Subscriber";
|
|
111
|
+
|
|
112
|
+
@customElement("my-element")
|
|
113
|
+
export class SonicComponent extends Fetcher(Subscriber(LitElement)) {
|
|
114
|
+
@property() email = "";
|
|
115
|
+
@property() first_name = "";
|
|
116
|
+
@property() last_name = "";
|
|
117
|
+
|
|
118
|
+
render() {
|
|
119
|
+
return html`<div>
|
|
120
|
+
${this.first_name} ${this.last_name} : ${this.email}
|
|
121
|
+
</div>`;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
</template>
|
|
125
|
+
</sonic-code>
|
|
126
|
+
|
|
127
|
+
In `main.ts` or `main.js` or any other component that uses it to be compiled
|
|
128
|
+
|
|
129
|
+
<sonic-code language="typescript">
|
|
130
|
+
<template>
|
|
131
|
+
import "./my-element";
|
|
132
|
+
</template>
|
|
133
|
+
</sonic-code>
|
|
134
|
+
|
|
135
|
+
In the HTML of a JS or TS component or in the HTML of the web page containing the compiled JS:
|
|
136
|
+
|
|
137
|
+
<sonic-code language="html">
|
|
138
|
+
<template>
|
|
139
|
+
<my-element serviceURL="https://reqres.in" dataProvider="api/users/2" key="data"></my-element>
|
|
140
|
+
</template>
|
|
141
|
+
</sonic-code>
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# 🧱 Creating components
|
|
2
|
+
|
|
3
|
+
## Where to put it?
|
|
4
|
+
|
|
5
|
+
In this document, we consider the src directory of the project as the root.<br>
|
|
6
|
+
We describe how we organize our components as an example, however it depends on your project.
|
|
7
|
+
|
|
8
|
+
In concorde each component is currently organized in the following directory structure (at least we try):
|
|
9
|
+
|
|
10
|
+
- **/core/components/functional/component-name/component-name.ts**
|
|
11
|
+
Generic/functional/generally unstyled component.
|
|
12
|
+
The component usually doesn't use any other concrete components.
|
|
13
|
+
- **/core/components/ui/component-name/component-name.ts**
|
|
14
|
+
Generic but UI-oriented component.
|
|
15
|
+
The component usually only uses generic components and other UI components.
|
|
16
|
+
- **la-billetterie/components/atoms/component-name/component-name.ts**
|
|
17
|
+
The component is intended to have a concrete usage within our ticketing system **"la-billetterie"**.
|
|
18
|
+
It usually only uses generic components from `core` and possibly other atoms.
|
|
19
|
+
- **la-billetterie/components/concrete-destination/component-name/component-name.ts**
|
|
20
|
+
The component has a specific destination: (event / cart / gift card): `/components/destination/`
|
|
21
|
+
The component uses various components, usually from the `/components/atoms` directory.
|
|
22
|
+
It does not use components at the same level in the file hierarchy.
|
|
23
|
+
|
|
24
|
+
## Starting from a Simple Model
|
|
25
|
+
|
|
26
|
+
You can copy `example.ts` from the source to the desired destination to start with.
|
|
27
|
+
This file contains a web component in the form of a class that extends the `Subscriber` mixin, with a reactive property and a render function.
|
|
28
|
+
|
|
29
|
+
<sonic-code language="javascript">
|
|
30
|
+
<template>
|
|
31
|
+
import { html, LitElement } from "lit";
|
|
32
|
+
import { customElement, property } from "lit/decorators.js";
|
|
33
|
+
import Subscriber from "@supersoniks/concorde/core/mixins/Subscriber";
|
|
34
|
+
|
|
35
|
+
@customElement("sonic-example")
|
|
36
|
+
export class SonicComponent extends Subscriber(LitElement) {
|
|
37
|
+
@property() text = "Example";
|
|
38
|
+
render() {
|
|
39
|
+
return html`${this.text}`;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
</template>
|
|
43
|
+
</sonic-code>
|
|
44
|
+
|
|
45
|
+
**You can remove the dependency on `Subscriber`** if automatic population of the component with external data is not required.
|
|
46
|
+
For example, for a UI component:
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
<sonic-code language="javascript">
|
|
50
|
+
<template>
|
|
51
|
+
import { html, LitElement } from "lit";
|
|
52
|
+
import { customElement, property } from "lit/decorators.js";
|
|
53
|
+
|
|
54
|
+
@customElement("sonic-example")
|
|
55
|
+
export class SonicComponent extends LitElement {
|
|
56
|
+
@property() text = "Example";
|
|
57
|
+
render() {
|
|
58
|
+
return html`${this.text}`;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
</template>
|
|
62
|
+
</sonic-code>
|
|
63
|
+
|
|
64
|
+
Regarding `Subscriber`, see:
|
|
65
|
+
|
|
66
|
+
- [🔔 Subscriber](#docs/_core-concept/subscriber.md/subscriber)
|
|
67
|
+
- [🥨 Sharing Data](#docs/_getting-started/pubsub.md/pubsub)
|
|
68
|
+
|
|
69
|
+
### Naming the Component
|
|
70
|
+
|
|
71
|
+
The class name is not necessarily important. However, it is important to **give it a component name prefixed with "sonic"** (or a prefix of your own) using the dedicated metadata already present in the copied document. For example, a button component would be named as follows:
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
<sonic-code language="typescript">
|
|
75
|
+
<template>
|
|
76
|
+
@customElement("sonic-button")
|
|
77
|
+
</template>
|
|
78
|
+
</sonic-code>
|
|
79
|
+
|
|
80
|
+
For less generic components with a specific destination, we advise to include the destination in the name.
|
|
81
|
+
For example, for a "title" component in the "event" destination, the name would be simply:
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
<sonic-code language="typescript">
|
|
85
|
+
<template>
|
|
86
|
+
@customElement("sonic-event-title")
|
|
87
|
+
</template>
|
|
88
|
+
</sonic-code>
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
## Modifying It
|
|
92
|
+
|
|
93
|
+
#### Creating Reactive Properties and Modifying the Render Function
|
|
94
|
+
|
|
95
|
+
To do this, study the functioning of https://lit.dev and also refer to [Subscriber](#docs/_core-concept/subscriber.md/subscriber).
|
|
96
|
+
|
|
97
|
+
#### HTML Structure of a Component
|
|
98
|
+
|
|
99
|
+
The HTML structure of a component should remain as simple as possible.
|
|
100
|
+
|
|
101
|
+
Ideally, there should be only one additional level of elements in addition to slots.
|
|
102
|
+
|
|
103
|
+
- **The main component is already a wrapper**.
|
|
104
|
+
It receives classes to manage its layout, but it should not style internal elements.
|
|
105
|
+
- **Slots handle the visual organization** of elements.
|
|
106
|
+
- **The specificity of the component is expressed in this additional level** by adding a list, a functional native element (e.g., button), or another component.
|
|
107
|
+
|
|
108
|
+
This leads to the creation of more components and thus raises questions about the hierarchical organization of files. However, this tends to atomize their roles.
|
|
109
|
+
|
|
110
|
+
## Referencing It
|
|
111
|
+
|
|
112
|
+
To compile the component, it needs to be referenced somewhere through an import statement. In particular, it is important to reference it in any component that uses it.
|
|
113
|
+
|
|
114
|
+
In the case where it can be directly used in a page, it should also be globally referenced, especially considering the creation of **specific bundles** in the future.
|
|
115
|
+
|
|
116
|
+
Here's where we add imports based on the component's location inside concorde as an example
|
|
117
|
+
|
|
118
|
+
- **/core/components/functional/component-name/component-name.ts**
|
|
119
|
+
In `/core/components/functional/functional.ts`, which is referenced in core.ts and imported in `index.ts`.
|
|
120
|
+
- **/core/components/ui/component-name/component-name.ts**
|
|
121
|
+
In `/core/components/ui/ui.ts`, which is referenced in core.ts and imported in `index.ts`.
|
|
122
|
+
- **la-billetterie/components/atoms/component-name/component-name.ts**
|
|
123
|
+
Nowhere else but where it will be used, except for possible **temporary** tests, for example, in `index.ts`.
|
|
124
|
+
- **la-billetterie/components/concrete-destination/component-name/component-name.ts**
|
|
125
|
+
In `la-billetterie/components/concrete-destination/destination-concrete.ts`.
|
|
126
|
+
If it's a new destination, you'll need to create the corresponding import .ts file and import it in `la-billetterie.ts`.
|
|
127
|
+
|
|
128
|
+
## Using It
|
|
129
|
+
|
|
130
|
+
As a reminder, the component is simply integrated into the context by adding a tag with the component's name, for example:
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
<sonic-code language="html">
|
|
134
|
+
<template>
|
|
135
|
+
<sonic-event-title></sonic-event-title>
|
|
136
|
+
</template>
|
|
137
|
+
</sonic-code>
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# 🥨 Sharing data
|
|
2
|
+
|
|
3
|
+
This section describes how we share data between graphical and non graphical components and classes.
|
|
4
|
+
|
|
5
|
+
Especialy, graphical components should not reference each other in order to **remain decoupled**.
|
|
6
|
+
|
|
7
|
+
Thats why we use **publish/subscribe** paradigm to addresse this issue.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## The Publisher
|
|
11
|
+
|
|
12
|
+
### Principle
|
|
13
|
+
|
|
14
|
+
* The **publisher** is a [JavaScript proxy](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Proxy) that contains some data.<br>**
|
|
15
|
+
Example of data : `{foo:{hello:["world"]}, bar:"baz"}`
|
|
16
|
+
|
|
17
|
+
* if a property of the **publisher** (dot syntax / array access), it returns another **publisher**.
|
|
18
|
+
Using the previous example `myPublisher.foo.hello` is also a publisher containing `["world"]`
|
|
19
|
+
|
|
20
|
+
* If the property doesn't exist at the time of the request, a publisher is created. its internal data is set to `null`.<br>
|
|
21
|
+
The value that can then be provided later.
|
|
22
|
+
|
|
23
|
+
* **Subscribers** can subscribe to the publisher's modifications and be updated in different ways (see : onAssign, onInternalMutation, startTemplateFilling).
|
|
24
|
+
|
|
25
|
+
* Data inside the publisher is updated by modifying the publisher itself, for example `myPublisher.foo.hello = ["Joey", "Smith"]`
|
|
26
|
+
|
|
27
|
+
* The publisher publishes modifications to any of its **Subscribers**.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
❇️ The order of data creation and subscription theoretically has no importance.
|
|
31
|
+
|
|
32
|
+
### Methods
|
|
33
|
+
|
|
34
|
+
* **set (complete replacement):** Assign/modifies the internal value of the publisher.
|
|
35
|
+
<sonic-code language="javascript">
|
|
36
|
+
<template>
|
|
37
|
+
publisher.set({foo:{hello:["world"]}, bar:"baz"});
|
|
38
|
+
</template>
|
|
39
|
+
</sonic-code>
|
|
40
|
+
* **get:** Get the internal value of the publisher.
|
|
41
|
+
<sonic-code language="javascript">
|
|
42
|
+
<template>
|
|
43
|
+
publisher.get() //{foo:{hello:["world"]}, bar:"baz"};
|
|
44
|
+
</template>
|
|
45
|
+
</sonic-code>
|
|
46
|
+
* **onAssign/offAssign:** Subscribe/unsubscribe to value assignments (via `set`) of the publisher.
|
|
47
|
+
<sonic-code language="javascript">
|
|
48
|
+
<template>
|
|
49
|
+
publisher.a.b.onAssign(console.log);
|
|
50
|
+
//indirect
|
|
51
|
+
publisher.a = {b:"dramatic change"}; //log: "dramatic change"
|
|
52
|
+
//via set
|
|
53
|
+
publisher.a.b.set(["Hello"]) //log: ["Hello"]
|
|
54
|
+
</template>
|
|
55
|
+
</sonic-code>
|
|
56
|
+
* **onInternalMutation/offInternalMutation:** Listen to any internal mutation regardless of its depth level.
|
|
57
|
+
<sonic-code language="javascript">
|
|
58
|
+
<template>
|
|
59
|
+
function save(){
|
|
60
|
+
console.log("Something has changed, let's save");
|
|
61
|
+
}
|
|
62
|
+
publisher.onInternalMutation(save);
|
|
63
|
+
publisher.a.b[0] = "e";
|
|
64
|
+
</template>
|
|
65
|
+
</sonic-code>
|
|
66
|
+
* **startTemplateFilling/stopTemplateFilling:** Fill an object model, a principle used with the Subscriber mixin on which most Concorde components rely.
|
|
67
|
+
<sonic-code language="javascript">
|
|
68
|
+
<template>
|
|
69
|
+
const fillableTemplate = { title: "A title to be replaced"};
|
|
70
|
+
publisher.startTemplateFilling(fillableTemplate);
|
|
71
|
+
state.title = "Good morning";
|
|
72
|
+
publisher.stopTemplateFilling(fillableTemplate);
|
|
73
|
+
state.title = "Oops";
|
|
74
|
+
console.log(fillableTemplate);
|
|
75
|
+
</template>
|
|
76
|
+
</sonic-code>
|
|
77
|
+
* **invalidate:** Flag the data as invalid. Used by sonic-fetch and sonic-list to trigger data reloading.
|
|
78
|
+
<sonic-code language="javascript">
|
|
79
|
+
<template>
|
|
80
|
+
publisher.invalidate();
|
|
81
|
+
</template>
|
|
82
|
+
</sonic-code>
|
|
83
|
+
* **onInvalidate/offInvalidate:** Subscribe/unsubscribe to data invalidation of the publisher. Used by sonic-fetch and sonic-list to trigger data reloading.
|
|
84
|
+
<sonic-code language="javascript">
|
|
85
|
+
<template>
|
|
86
|
+
function reloadData(){
|
|
87
|
+
console.log("Reload data to inject it again into the publisher");
|
|
88
|
+
}
|
|
89
|
+
publisher.onInvalidate(reloadData);
|
|
90
|
+
</template>
|
|
91
|
+
</sonic-code>
|
|
92
|
+
|
|
93
|
+
## DataProvider
|
|
94
|
+
|
|
95
|
+
Denotes the identifier of a publisher as referenced in the PublisherManager (see below).
|
|
96
|
+
Uses the dataProvider attribut in html tags to scop the content with some data.
|
|
97
|
+
see [Subscribers](#docs/_core-concept/subscriber.md/subscriber).
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
## PublisherManager
|
|
101
|
+
|
|
102
|
+
The **PublisherManager** is a utility class to get publishers
|
|
103
|
+
|
|
104
|
+
It plays a central role in the components, especially through the "subscriber" mixin.<br>
|
|
105
|
+
Automatic data communication between components in concorde uses this principle in conjunction with Lit's reactive properties. <br>
|
|
106
|
+
Refer to the documentation for [Subscriber](#docs/_core-concept/subscriber.md/subscriber).
|
|
107
|
+
|
|
108
|
+
<sonic-code language="javascript">
|
|
109
|
+
<template>
|
|
110
|
+
import { PublisherManager } from "publisherproxy";
|
|
111
|
+
let dataProvider = "cart";
|
|
112
|
+
let publisher = PublisherManager.get(dataProvider);
|
|
113
|
+
|
|
114
|
+
</template>
|
|
115
|
+
</sonic-code>
|
|
116
|
+
|
|
117
|
+
It is declared on the `window` object to allow usage in a web page, so the equivalent one-liner would be:
|
|
118
|
+
|
|
119
|
+
<sonic-code language="javascript">
|
|
120
|
+
<template>
|
|
121
|
+
let dataProvider = "cart";
|
|
122
|
+
let publisher = SonicPublisherManager.get(dataProvider);
|
|
123
|
+
|
|
124
|
+
</template>
|
|
125
|
+
</sonic-code>
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
## Basic Example
|
|
129
|
+
|
|
130
|
+
This example can be tested in a console when Concorde is loaded on the page (for example, in a ticketing system).
|
|
131
|
+
In a component, you will need to perform an `import` as explained earlier.
|
|
132
|
+
|
|
133
|
+
<sonic-code language="javascript">
|
|
134
|
+
<template>
|
|
135
|
+
// Anywhere, anytime
|
|
136
|
+
SonicPublisherManager.get("mySubject").title.onAssign(console.log)
|
|
137
|
+
|
|
138
|
+
</template>
|
|
139
|
+
</sonic-code>
|
|
140
|
+
|
|
141
|
+
<sonic-code language="javascript">
|
|
142
|
+
<template>
|
|
143
|
+
// Anywhere, anytime
|
|
144
|
+
let publisher = SonicPublisherManager.get("mySubject");
|
|
145
|
+
// ...
|
|
146
|
+
publisher.set({title: "A title"});
|
|
147
|
+
publisher.title.set("A second title");
|
|
148
|
+
|
|
149
|
+
</template>
|
|
150
|
+
</sonic-code>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Introduction
|
|
2
|
+
|
|
3
|
+
## What is Concorde ?
|
|
4
|
+
|
|
5
|
+
Based on [lit.dev](https://lit.dev), Concorde is a collection of functional & UI webcomponents, created to build easily shared components, beetween apps and websites. Or even to build a website or an app from scratch.
|
|
6
|
+
It's like a toolbox to build user interfaces, faster, where everything is scoped, but preserving graphical consistency in set a few css variables.
|
|
7
|
+
|
|
8
|
+
## Why and use case
|
|
9
|
+
|
|
10
|
+
At Supersoniks, we've created a ticketing management system that needs shared components which could be implemented in mobile apps, modern websites, and also old ones made in php, without bundlers or whatever.
|
|
11
|
+
Instead of creating a new library for each type of project, which would become hard to maintain, we've decided to create one shared library, that could be used in any environment and pre-bundled for legacy environment.
|
|
12
|
+
Webcomponents appeared to be a the perfect solution to guarantee that compatibility with all past, present and futures stacks.
|
|
13
|
+
|
|
14
|
+
### Functionnal features
|
|
15
|
+
|
|
16
|
+
* Fetching data, lists, queue with lazyload, etc.
|
|
17
|
+
* Data management with Publisher / Subscriber pattern
|
|
18
|
+
* Data binding
|
|
19
|
+
* Form management ("doux Jésus")
|
|
20
|
+
* Simple router, state component,...
|
|
21
|
+
|
|
22
|
+
### Tools
|
|
23
|
+
|
|
24
|
+
* Lit, of course
|
|
25
|
+
* Typescript
|
|
26
|
+
* Vite
|
|
27
|
+
* Tailwind (not in the core, but in the starter kit)
|
|
28
|
+
|
|
29
|
+
## Start a new project from scratch ?
|
|
30
|
+
|
|
31
|
+
A new project with Vite, Typescript and Tailwind already configured and a simple example of a subscriber component :
|
|
32
|
+
|
|
33
|
+
<sonic-code language="bash">
|
|
34
|
+
<template>
|
|
35
|
+
npx @supersoniks/create-concorde-ts-starter "project_name"
|
|
36
|
+
</template>
|
|
37
|
+
</sonic-code>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Adding styles
|
|
2
|
+
|
|
3
|
+
## Normal Behavior
|
|
4
|
+
|
|
5
|
+
No style crosses the shadow root of a component, except for inheritable properties (which have the "inherit" property possible) and CSS variables.
|
|
6
|
+
Properties integrated via a "[slot](https://developer.mozilla.org/en/docs/Web/HTML/Element/slot)" remain stylizable in a conventional way.
|
|
7
|
+
|
|
8
|
+
- **During creation / from the inside:**
|
|
9
|
+
- We edit the [static "styles" property of the lit component](https://lit.dev/docs/components/styles/), which can also reference shared and dynamic styles.
|
|
10
|
+
These styles are scoped and do not impact the outside.
|
|
11
|
+
- We use CSS variables as the value of properties intended to be customized from the outside.
|
|
12
|
+
For each variable, we define a default value to have a simple but consistent base style.
|
|
13
|
+
- We only rewrite inheritable properties with hard values if they are truly specific to the component.
|
|
14
|
+
- The `<style>` tag as a direct child can be used as a last resort, especially if there is a need for particularly dynamic customization. Performance is reduced.
|
|
15
|
+
- **During use / from the outside:**
|
|
16
|
+
We define values for **inheritable CSS properties** (e.g., font-\_, color...) using tools like Tailwind.
|
|
17
|
+
We modify the value of **CSS variables** used by the component.
|
|
18
|
+
|
|
19
|
+
## Choosing Style Presets via Reactive Properties:
|
|
20
|
+
|
|
21
|
+
The declaration of reactive properties is useful for selecting a particular configuration that mostly affects a set of properties.
|
|
22
|
+
|
|
23
|
+
For example, a `size` property (xs, sm, md, xl) will affect margins, font, line heights to align them with the corresponding CSS vars, which can be customized using the methods mentioned earlier if necessary.
|
|
24
|
+
|
|
25
|
+
It is recommended to use the `{reflect: true}` property for reactive properties that have an associated style on the `:host()`. For example: `:host([type='primary']){...}`
|
|
26
|
+
|
|
27
|
+
☢️ **Caution:** Passing class names via reactive properties / HTML attributes of the component should be avoided as it can quickly lead to difficult-to-manage situations.
|
|
28
|
+
|
|
29
|
+
#### CSS "display" Property
|
|
30
|
+
|
|
31
|
+
By default, the display property is `inline`.
|
|
32
|
+
Therefore, be careful to define it according to the needs, as one might mistakenly expect it to be `block` as with a regular `<div>`.
|
|
33
|
+
|
|
34
|
+
☢️ **Caution:** Defining the `display` property as `contents` may seem attractive at first, but:
|
|
35
|
+
|
|
36
|
+
- It almost always leads to the creation of wrappers to style the content (instead of using `:host`).
|
|
37
|
+
- It is no longer possible to directly add classes to the component or style it from the outside.
|
|
38
|
+
Ultimately, the amount of code to write increases significantly.
|
|
39
|
+
|
|
40
|
+
## TAILWIND Functional Classes
|
|
41
|
+
|
|
42
|
+
[tailwind](https://tailwindcss.com/) has been integrated into Concorde and is available in scoped components (with Shadow DOM).
|
|
43
|
+
To use it, you need to import the following:
|
|
44
|
+
|
|
45
|
+
<sonic-code language="javascript">
|
|
46
|
+
<template>
|
|
47
|
+
import { tailwind } from "@supersoniks/concorde/la-billetterie/ui/theme/theme";
|
|
48
|
+
</template>
|
|
49
|
+
</sonic-code>
|
|
50
|
+
|
|
51
|
+
Then include the `tailwind` style in the static `styles` property of the component:
|
|
52
|
+
|
|
53
|
+
<sonic-code language="javascript">
|
|
54
|
+
<template>
|
|
55
|
+
static styles = [tailwind];
|
|
56
|
+
</template>
|
|
57
|
+
</sonic-code>
|
|
58
|
+
|
|
59
|
+
Finally, use it in the HTML within the render function:
|
|
60
|
+
|
|
61
|
+
<sonic-code language="html">
|
|
62
|
+
<template>
|
|
63
|
+
<p class="m-2">A paragraph with margin</p>
|
|
64
|
+
</template>
|
|
65
|
+
</sonic-code>
|
|
66
|
+
|
|
67
|
+
The colors from Concorde's theme are referenced in Tailwind's theme.
|
|
68
|
+
|
|
69
|
+
## Operation without Shadow DOM
|
|
70
|
+
|
|
71
|
+
### Usefulness
|
|
72
|
+
|
|
73
|
+
This operation is particularly useful when it comes to **adding behavior to a simple existing element**.
|
|
74
|
+
It may also become necessary to establish **compatibility with a traditional JS library**.
|
|
75
|
+
|
|
76
|
+
For example, with a text input:
|
|
77
|
+
|
|
78
|
+
- Trigger automatic data or filter update when typing text.
|
|
79
|
+
- Automatic formatting.
|
|
80
|
+
- Constraints that cannot be handled by native methods.
|
|
81
|
+
|
|
82
|
+
### Consequences
|
|
83
|
+
|
|
84
|
+
If there is no shadow DOM (see the **noShadowDom** property of **Subscriber**):
|
|
85
|
+
|
|
86
|
+
- Styling using the static "styles" property of the lit component will not be applied.
|
|
87
|
+
- The element and its content can be styled in a traditional manner.
|
|
88
|
+
|
|
89
|
+
For example, the components `queue`, `list`, and `fetch` do not have a shadow DOM.
|
|
90
|
+
|
|
91
|
+
ℹ️ **Note:** Specifically in this case, it may be useful to set the `display` property to `contents`.
|