@getvitops/generator 0.1.0
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/README.md +35 -0
- package/assets/bricks/elements/carousel.php +89 -0
- package/assets/bricks/elements/centered.php +128 -0
- package/assets/bricks/elements/color-scheme-toggle.php +61 -0
- package/assets/bricks/elements/copy-button.php +65 -0
- package/assets/bricks/elements/dismissable.php +93 -0
- package/assets/bricks/elements/entries.php +96 -0
- package/assets/bricks/elements/image-compare.php +132 -0
- package/assets/bricks/elements/multi-field.php +148 -0
- package/assets/bricks/elements/sitenav.php +298 -0
- package/assets/bricks/elements/split-link.php +170 -0
- package/assets/bricks/elements/split-panel.php +155 -0
- package/assets/bricks/elements/split.php +83 -0
- package/assets/bricks/load.php +129 -0
- package/assets/css/animation.css +526 -0
- package/assets/css/global.css +17 -0
- package/assets/css/index.css +58 -0
- package/assets/css/layout.css +723 -0
- package/assets/css/patterns/anchor-link.css +66 -0
- package/assets/css/patterns/banner.css +64 -0
- package/assets/css/patterns/carousel.css +269 -0
- package/assets/css/patterns/cluster.css +64 -0
- package/assets/css/patterns/code.css +17 -0
- package/assets/css/patterns/combobox.css +97 -0
- package/assets/css/patterns/comment.css +88 -0
- package/assets/css/patterns/copy.css +82 -0
- package/assets/css/patterns/details.css +87 -0
- package/assets/css/patterns/dialog.css +99 -0
- package/assets/css/patterns/drawer.css +108 -0
- package/assets/css/patterns/dropdown.css +45 -0
- package/assets/css/patterns/forms.css +335 -0
- package/assets/css/patterns/grouped.css +86 -0
- package/assets/css/patterns/horizontal-scroll.css +40 -0
- package/assets/css/patterns/icon.css +72 -0
- package/assets/css/patterns/lightbox.css +156 -0
- package/assets/css/patterns/list.css +272 -0
- package/assets/css/patterns/marquee.css +68 -0
- package/assets/css/patterns/masonry.css +40 -0
- package/assets/css/patterns/media.css +70 -0
- package/assets/css/patterns/nav.css +241 -0
- package/assets/css/patterns/notification.css +114 -0
- package/assets/css/patterns/overlay.css +28 -0
- package/assets/css/patterns/popover.css +68 -0
- package/assets/css/patterns/pull-quote.css +71 -0
- package/assets/css/patterns/scroll-based.css +227 -0
- package/assets/css/patterns/scroll-target.css +124 -0
- package/assets/css/patterns/separator.css +130 -0
- package/assets/css/patterns/sitenav.css +582 -0
- package/assets/css/patterns/split-link.css +113 -0
- package/assets/css/patterns/splitter.css +212 -0
- package/assets/css/patterns/stack.css +67 -0
- package/assets/css/patterns/sticky.css +127 -0
- package/assets/css/patterns/subgrid.css +178 -0
- package/assets/css/patterns/svg.css +166 -0
- package/assets/css/patterns/table.css +106 -0
- package/assets/css/patterns/tag.css +75 -0
- package/assets/css/patterns/text-effects.css +317 -0
- package/assets/css/patterns/tooltip.css +68 -0
- package/assets/css/patterns/tree.css +126 -0
- package/assets/css/utilities.css +351 -0
- package/assets/js/deferred.js +1 -0
- package/assets/js/elements.js +887 -0
- package/assets/js/polyfills/adoptedStyleSheets.js +1 -0
- package/assets/js/polyfills/css-anchor-positioning-fn.js +17 -0
- package/assets/js/polyfills/global.esm.js +1 -0
- package/assets/js/polyfills/popover.js +63 -0
- package/assets/js/polyfills/template-shadowroot.js +24 -0
- package/assets/js/polyfills/webcomponents-bundle.js +27 -0
- package/assets/js/polyfills.js +1 -0
- package/dist/index.d.mts +1425 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2611 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +33 -0
- package/schema.json +508 -0
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# @getvitops/generator
|
|
2
|
+
|
|
3
|
+
Generate design-system outputs — **Bricks** (WordPress), standalone **CSS**, and **Tailwind
|
|
4
|
+
v4** (Astro/EmDash) — from a single `design-system.json`. This is the library that powers
|
|
5
|
+
[`@getvitops/cli`](https://www.npmjs.com/package/@getvitops/cli) and
|
|
6
|
+
[`@getvitops/vite`](https://www.npmjs.com/package/@getvitops/vite).
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
import { generate, validate, defaultConfig } from '@getvitops/generator';
|
|
10
|
+
|
|
11
|
+
await generate({
|
|
12
|
+
input: './design-system.json', // path or a config object
|
|
13
|
+
format: 'tailwind', // 'bricks' | 'css' | 'tailwind'
|
|
14
|
+
outDir: './src/styles',
|
|
15
|
+
});
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## API
|
|
19
|
+
|
|
20
|
+
- `generate({ input, format, outDir })` → writes the chosen format into `outDir`.
|
|
21
|
+
- `validate(configOrObject)` → `{ ok, errors }` against the schema.
|
|
22
|
+
- `defaultConfig()` → a complete starter `DesignSystem`.
|
|
23
|
+
- `DesignSystemSchema` / `jsonSchema` / `SCHEMA_URL` — the `zod/mini` schema, its JSON Schema,
|
|
24
|
+
and the published schema URL. The schema is the single source of truth (types + validation +
|
|
25
|
+
JSON Schema all derive from it). The JSON Schema ships as `@getvitops/generator/schema.json`.
|
|
26
|
+
|
|
27
|
+
## Output per format
|
|
28
|
+
|
|
29
|
+
| format | writes |
|
|
30
|
+
| ---------- | -------------------------------------------------------------------------------------------------------- |
|
|
31
|
+
| `tailwind` | `tailwind.css` (self-contained, `@import "tailwindcss"`) + `tokens.json` |
|
|
32
|
+
| `css` | `styles.css` (bundled, standalone) + `tokens.json` + `design-manifest.json` |
|
|
33
|
+
| `bricks` | `styles.min.css`, `bricks-colors-*.json`, `bricks-variables.json`, `tokens.json`, JS, `bricks/`, `docs/` |
|
|
34
|
+
|
|
35
|
+
See the [`design-system.json` schema](./schema.json) for the config shape.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Vitops — Carousel element (Bricks Builder).
|
|
4
|
+
*
|
|
5
|
+
* Renders the <wc-carousel> Lit component (src/web-components/WCCarousel.ts): an
|
|
6
|
+
* infinite-loop carousel that progressively enhances the CSS-only `.carousel`. Each
|
|
7
|
+
* direct child is a slide. Without JS the `.carousel` classes still yield a working
|
|
8
|
+
* (non-looping) scroll-snap carousel, so the builder canvas stays functional.
|
|
9
|
+
*
|
|
10
|
+
* The `.carousel` base rides on the built-in "CSS classes" setting (defaulted below) so
|
|
11
|
+
* it applies in the canvas and the frontend. Add modifier classes there:
|
|
12
|
+
* `carousel--scroll-buttons`, `carousel--scroll-markers`, `carousel--auto-pages`.
|
|
13
|
+
*
|
|
14
|
+
* Owned by the framework repo (vitops: bricks/elements/); copied into the theme's
|
|
15
|
+
* dist/bricks/ on build — do not hand-edit in the theme.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
if ( ! defined( 'ABSPATH' ) ) {
|
|
19
|
+
exit;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
class Vitops_Element_Carousel extends \Bricks\Element {
|
|
23
|
+
public $category = 'vitops';
|
|
24
|
+
public $name = 'vitops-carousel';
|
|
25
|
+
public $icon = 'ti-layout-slider-alt';
|
|
26
|
+
public $css_selector = 'wc-carousel';
|
|
27
|
+
public $nestable = true;
|
|
28
|
+
public $vue_component = 'bricks-nestable';
|
|
29
|
+
|
|
30
|
+
public function get_label() {
|
|
31
|
+
return esc_html__( 'Carousel', 'bricks' );
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public function get_keywords() {
|
|
35
|
+
return array( 'carousel', 'slider', 'slides', 'gallery', 'scroll', 'vitops' );
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public function set_controls() {
|
|
39
|
+
$this->controls['autoplay'] = array(
|
|
40
|
+
'tab' => 'content',
|
|
41
|
+
'label' => esc_html__( 'Autoplay interval (ms)', 'bricks' ),
|
|
42
|
+
'type' => 'number',
|
|
43
|
+
'placeholder' => '0',
|
|
44
|
+
'description' => esc_html__( 'Milliseconds between slides. Leave empty / 0 to disable.', 'bricks' ),
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
$this->controls['label'] = array(
|
|
48
|
+
'tab' => 'content',
|
|
49
|
+
'label' => esc_html__( 'Accessible label (aria-label)', 'bricks' ),
|
|
50
|
+
'type' => 'text',
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
$this->controls['modifiersInfo'] = array(
|
|
54
|
+
'tab' => 'content',
|
|
55
|
+
'type' => 'info',
|
|
56
|
+
'content' => esc_html__( 'Add modifier classes in "CSS classes": carousel--scroll-buttons, carousel--scroll-markers, carousel--auto-pages. Each direct child is a slide.', 'bricks' ),
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
// Base carousel class defaulted onto the built-in "CSS classes" setting.
|
|
60
|
+
$this->controls['_cssClasses']['default'] = 'carousel';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Seed three empty slides — the author fills each.
|
|
64
|
+
public function get_nestable_children() {
|
|
65
|
+
return array(
|
|
66
|
+
array( 'name' => 'block', 'label' => esc_html__( 'Slide 1', 'bricks' ) ),
|
|
67
|
+
array( 'name' => 'block', 'label' => esc_html__( 'Slide 2', 'bricks' ) ),
|
|
68
|
+
array( 'name' => 'block', 'label' => esc_html__( 'Slide 3', 'bricks' ) ),
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public function render() {
|
|
73
|
+
$s = $this->settings;
|
|
74
|
+
$attrs = array();
|
|
75
|
+
|
|
76
|
+
if ( isset( $s['autoplay'] ) && '' !== $s['autoplay'] && (int) $s['autoplay'] > 0 ) {
|
|
77
|
+
$attrs[] = 'autoplay="' . esc_attr( $s['autoplay'] ) . '"';
|
|
78
|
+
}
|
|
79
|
+
if ( ! empty( $s['label'] ) ) {
|
|
80
|
+
$attrs[] = 'aria-label="' . esc_attr( $s['label'] ) . '"';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
$attr_str = implode( ' ', $attrs );
|
|
84
|
+
|
|
85
|
+
echo "<wc-carousel {$attr_str} {$this->render_attributes( '_root' )}>";
|
|
86
|
+
echo \Bricks\Frontend::render_children( $this );
|
|
87
|
+
echo '</wc-carousel>';
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Vitops — Centered layout element (Bricks Builder).
|
|
4
|
+
*
|
|
5
|
+
* A nestable container that renders the framework's named-track grid, `.centered`
|
|
6
|
+
* (src/css/layout.css). Children auto-place in the reading `measure` track; a child
|
|
7
|
+
* widens by adding `breakout` / `spotlight` / `fullbleed` (+ responsive `-sm/-md/-lg/-xl`)
|
|
8
|
+
* in its own Bricks "CSS classes" field.
|
|
9
|
+
*
|
|
10
|
+
* The framework classes ride on the built-in "CSS classes" setting (defaulted below):
|
|
11
|
+
* a nestable element's root is assembled from settings in the builder canvas, so classes
|
|
12
|
+
* added only in render()/set_root_attributes() never appear there — _cssClasses does.
|
|
13
|
+
*
|
|
14
|
+
* Owned by the framework repo (vitops: bricks/elements/); copied into the theme's
|
|
15
|
+
* dist/bricks/ on build — do not hand-edit in the theme.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
if ( ! defined( 'ABSPATH' ) ) {
|
|
19
|
+
exit;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
class Vitops_Element_Centered extends \Bricks\Element {
|
|
23
|
+
public $category = 'vitops';
|
|
24
|
+
public $name = 'vitops-centered';
|
|
25
|
+
public $icon = 'ti-layout-width-default';
|
|
26
|
+
public $css_selector = '.centered';
|
|
27
|
+
public $nestable = true;
|
|
28
|
+
public $vue_component = 'bricks-nestable';
|
|
29
|
+
|
|
30
|
+
public function get_label() {
|
|
31
|
+
return esc_html__( 'Centered', 'bricks' );
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public function get_keywords() {
|
|
35
|
+
return [ 'centered', 'measure', 'grid', 'container', 'layout', 'track', 'vitops' ];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public function set_control_groups() {
|
|
39
|
+
$this->control_groups['tracks'] = [
|
|
40
|
+
'title' => esc_html__( 'Track widths', 'bricks' ),
|
|
41
|
+
'tab' => 'content',
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public function set_controls() {
|
|
46
|
+
$this->controls['tag'] = [
|
|
47
|
+
'tab' => 'content',
|
|
48
|
+
'label' => esc_html__( 'HTML tag', 'bricks' ),
|
|
49
|
+
'type' => 'select',
|
|
50
|
+
'inline' => true,
|
|
51
|
+
'options' => [
|
|
52
|
+
'div' => 'div',
|
|
53
|
+
'section' => 'section',
|
|
54
|
+
'article' => 'article',
|
|
55
|
+
'aside' => 'aside',
|
|
56
|
+
'main' => 'main',
|
|
57
|
+
'header' => 'header',
|
|
58
|
+
'footer' => 'footer',
|
|
59
|
+
'nav' => 'nav',
|
|
60
|
+
],
|
|
61
|
+
'default' => 'div',
|
|
62
|
+
'lowercase' => true,
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
// Each width control writes a CSS custom property onto the element root
|
|
66
|
+
// (.centered), where the grid template reads it. Defaults mirror layout.css.
|
|
67
|
+
$this->controls['measure'] = [
|
|
68
|
+
'tab' => 'content',
|
|
69
|
+
'group' => 'tracks',
|
|
70
|
+
'label' => esc_html__( 'Measure (reading width)', 'bricks' ),
|
|
71
|
+
'type' => 'number',
|
|
72
|
+
'units' => true,
|
|
73
|
+
'default' => '65ch',
|
|
74
|
+
'css' => [ [ 'property' => '--width-measure', 'selector' => '' ] ],
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
$this->controls['breakout'] = [
|
|
78
|
+
'tab' => 'content',
|
|
79
|
+
'group' => 'tracks',
|
|
80
|
+
'label' => esc_html__( 'Breakout width', 'bricks' ),
|
|
81
|
+
'type' => 'number',
|
|
82
|
+
'units' => true,
|
|
83
|
+
'default' => '90ch',
|
|
84
|
+
'css' => [ [ 'property' => '--width-breakout', 'selector' => '' ] ],
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
$this->controls['spotlight'] = [
|
|
88
|
+
'tab' => 'content',
|
|
89
|
+
'group' => 'tracks',
|
|
90
|
+
'label' => esc_html__( 'Spotlight width', 'bricks' ),
|
|
91
|
+
'type' => 'number',
|
|
92
|
+
'units' => true,
|
|
93
|
+
'default' => '120ch',
|
|
94
|
+
'css' => [ [ 'property' => '--width-spotlight', 'selector' => '' ] ],
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
// Gutter is a `text` control so it accepts the framework default clamp().
|
|
98
|
+
$this->controls['gutter'] = [
|
|
99
|
+
'tab' => 'content',
|
|
100
|
+
'group' => 'tracks',
|
|
101
|
+
'label' => esc_html__( 'Gutter', 'bricks' ),
|
|
102
|
+
'type' => 'text',
|
|
103
|
+
'placeholder' => 'clamp(1rem, 4cqi, 3rem)',
|
|
104
|
+
'css' => [ [ 'property' => '--gutter', 'selector' => '' ] ],
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
// Framework classes default onto the built-in "CSS classes" setting so they
|
|
108
|
+
// apply in the builder canvas AND the frontend. `rhythm` (relationship-based
|
|
109
|
+
// vertical spacing) is on by default — remove it in the CSS-classes field to
|
|
110
|
+
// disable. (It's a class, not a checkbox, because a nestable element can't
|
|
111
|
+
// reflect a PHP-computed root class in the builder.)
|
|
112
|
+
$this->controls['_cssClasses']['default'] = 'centered rhythm';
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// No seeded children: a Centered container starts empty. Each direct child is
|
|
116
|
+
// auto-placed in the reading `measure` track; the author widens one by adding
|
|
117
|
+
// `breakout` / `spotlight` / `fullbleed` (+ `-sm/-md/-lg/-xl`) in its own
|
|
118
|
+
// Bricks "CSS classes" field — no wrapper or preset child needed.
|
|
119
|
+
|
|
120
|
+
public function render() {
|
|
121
|
+
// $this->tag is resolved from the `tag` setting by the base (get_tag()).
|
|
122
|
+
// render_children() returns child HTML on the frontend and the nestable
|
|
123
|
+
// drag-drop placeholder inside the builder.
|
|
124
|
+
echo "<{$this->tag} {$this->render_attributes( '_root' )}>";
|
|
125
|
+
echo \Bricks\Frontend::render_children( $this );
|
|
126
|
+
echo "</{$this->tag}>";
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Vitops — Color Scheme Toggle element (Bricks Builder).
|
|
4
|
+
*
|
|
5
|
+
* Renders the <color-scheme-toggle> Lit component (src/web-components/WCColorSchemeToggle.ts):
|
|
6
|
+
* a segmented System / Light / Dark theme toggle, hidden until JS loads. Optionally seed
|
|
7
|
+
* the initial `scheme`.
|
|
8
|
+
*
|
|
9
|
+
* Non-nestable: PHP render() runs in the builder canvas too, so the toggle upgrades
|
|
10
|
+
* live while editing.
|
|
11
|
+
*
|
|
12
|
+
* Owned by the framework repo (vitops: bricks/elements/); copied into the theme's
|
|
13
|
+
* dist/bricks/ on build — do not hand-edit in the theme.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
if ( ! defined( 'ABSPATH' ) ) {
|
|
17
|
+
exit;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
class Vitops_Element_Color_Scheme_Toggle extends \Bricks\Element {
|
|
21
|
+
public $category = 'vitops';
|
|
22
|
+
public $name = 'vitops-color-scheme-toggle';
|
|
23
|
+
public $icon = 'ti-shine';
|
|
24
|
+
public $css_selector = 'color-scheme-toggle';
|
|
25
|
+
|
|
26
|
+
public function get_label() {
|
|
27
|
+
return esc_html__( 'Color Scheme Toggle', 'bricks' );
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public function get_keywords() {
|
|
31
|
+
return array( 'color', 'scheme', 'theme', 'dark', 'light', 'toggle', 'vitops' );
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public function set_controls() {
|
|
35
|
+
$this->controls['scheme'] = array(
|
|
36
|
+
'tab' => 'content',
|
|
37
|
+
'label' => esc_html__( 'Initial scheme', 'bricks' ),
|
|
38
|
+
'type' => 'select',
|
|
39
|
+
'inline' => true,
|
|
40
|
+
'options' => array(
|
|
41
|
+
'system' => esc_html__( 'System', 'bricks' ),
|
|
42
|
+
'light' => esc_html__( 'Light', 'bricks' ),
|
|
43
|
+
'dark' => esc_html__( 'Dark', 'bricks' ),
|
|
44
|
+
),
|
|
45
|
+
'placeholder' => esc_html__( 'System', 'bricks' ),
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public function render() {
|
|
50
|
+
$s = $this->settings;
|
|
51
|
+
$attrs = array();
|
|
52
|
+
|
|
53
|
+
if ( ! empty( $s['scheme'] ) ) {
|
|
54
|
+
$attrs[] = 'scheme="' . esc_attr( $s['scheme'] ) . '"';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
$attr_str = implode( ' ', $attrs );
|
|
58
|
+
|
|
59
|
+
echo "<color-scheme-toggle {$attr_str} {$this->render_attributes( '_root' )}></color-scheme-toggle>";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Vitops — Copy Button element (Bricks Builder).
|
|
4
|
+
*
|
|
5
|
+
* Renders the <copy-button> Lit component (src/web-components/WCCopy.ts): a
|
|
6
|
+
* copy-to-clipboard button, hidden until connected (Clipboard API gate). The `value`
|
|
7
|
+
* is copied; `label` is the button text (falls back to slotted text).
|
|
8
|
+
*
|
|
9
|
+
* Non-nestable: PHP render() runs in the builder canvas too, so the button upgrades
|
|
10
|
+
* live while editing.
|
|
11
|
+
*
|
|
12
|
+
* Owned by the framework repo (vitops: bricks/elements/); copied into the theme's
|
|
13
|
+
* dist/bricks/ on build — do not hand-edit in the theme.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
if ( ! defined( 'ABSPATH' ) ) {
|
|
17
|
+
exit;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
class Vitops_Element_Copy extends \Bricks\Element {
|
|
21
|
+
public $category = 'vitops';
|
|
22
|
+
public $name = 'vitops-copy-button';
|
|
23
|
+
public $icon = 'ti-clipboard';
|
|
24
|
+
public $css_selector = 'copy-button';
|
|
25
|
+
|
|
26
|
+
public function get_label() {
|
|
27
|
+
return esc_html__( 'Copy Button', 'bricks' );
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public function get_keywords() {
|
|
31
|
+
return array( 'copy', 'clipboard', 'button', 'vitops' );
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public function set_controls() {
|
|
35
|
+
$this->controls['value'] = array(
|
|
36
|
+
'tab' => 'content',
|
|
37
|
+
'label' => esc_html__( 'Value to copy', 'bricks' ),
|
|
38
|
+
'type' => 'text',
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
$this->controls['label'] = array(
|
|
42
|
+
'tab' => 'content',
|
|
43
|
+
'label' => esc_html__( 'Button label', 'bricks' ),
|
|
44
|
+
'type' => 'text',
|
|
45
|
+
'placeholder' => esc_html__( 'Copy to clipboard', 'bricks' ),
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public function render() {
|
|
50
|
+
$s = $this->settings;
|
|
51
|
+
$attrs = array();
|
|
52
|
+
|
|
53
|
+
if ( isset( $s['value'] ) && '' !== $s['value'] ) {
|
|
54
|
+
$attrs[] = 'value="' . esc_attr( $s['value'] ) . '"';
|
|
55
|
+
}
|
|
56
|
+
if ( ! empty( $s['label'] ) ) {
|
|
57
|
+
$attrs[] = 'label="' . esc_attr( $s['label'] ) . '"';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
$attr_str = implode( ' ', $attrs );
|
|
61
|
+
$fallback = ! empty( $s['label'] ) ? esc_html( $s['label'] ) : esc_html__( 'Copy to clipboard', 'bricks' );
|
|
62
|
+
|
|
63
|
+
echo "<copy-button {$attr_str} {$this->render_attributes( '_root' )}>{$fallback}</copy-button>";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Vitops — Dismissable element (Bricks Builder).
|
|
4
|
+
*
|
|
5
|
+
* Renders the <wc-dismissable> Lit component (src/web-components/WCDismissable.ts): a
|
|
6
|
+
* light-DOM progressive-enhancement wrapper. A click on any descendant marked
|
|
7
|
+
* `data-dismiss` (e.g. the seeded close button) fades the wrapper out and removes it.
|
|
8
|
+
* Optional `duration` auto-dismisses after N ms; `exit` sets the fade time.
|
|
9
|
+
*
|
|
10
|
+
* Without JS the wrapper is an inert unknown tag and its content still renders, so the
|
|
11
|
+
* builder canvas stays functional.
|
|
12
|
+
*
|
|
13
|
+
* Owned by the framework repo (vitops: bricks/elements/); copied into the theme's
|
|
14
|
+
* dist/bricks/ on build — do not hand-edit in the theme.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
if ( ! defined( 'ABSPATH' ) ) {
|
|
18
|
+
exit;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
class Vitops_Element_Dismissable extends \Bricks\Element {
|
|
22
|
+
public $category = 'vitops';
|
|
23
|
+
public $name = 'vitops-dismissable';
|
|
24
|
+
public $icon = 'ti-close';
|
|
25
|
+
public $css_selector = 'wc-dismissable';
|
|
26
|
+
public $nestable = true;
|
|
27
|
+
public $vue_component = 'bricks-nestable';
|
|
28
|
+
|
|
29
|
+
public function get_label() {
|
|
30
|
+
return esc_html__( 'Dismissable', 'bricks' );
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public function get_keywords() {
|
|
34
|
+
return array( 'dismiss', 'close', 'banner', 'notice', 'alert', 'vitops' );
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public function set_controls() {
|
|
38
|
+
$this->controls['duration'] = array(
|
|
39
|
+
'tab' => 'content',
|
|
40
|
+
'label' => esc_html__( 'Auto-dismiss after (ms)', 'bricks' ),
|
|
41
|
+
'type' => 'number',
|
|
42
|
+
'description' => esc_html__( 'Leave empty to require a click on a [data-dismiss] element.', 'bricks' ),
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
$this->controls['exit'] = array(
|
|
46
|
+
'tab' => 'content',
|
|
47
|
+
'label' => esc_html__( 'Fade-out time (ms)', 'bricks' ),
|
|
48
|
+
'type' => 'number',
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
$this->controls['dismissInfo'] = array(
|
|
52
|
+
'tab' => 'content',
|
|
53
|
+
'type' => 'info',
|
|
54
|
+
'content' => esc_html__( 'Any child with a data-dismiss attribute acts as a close trigger. The seeded button already has it.', 'bricks' ),
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Seed content + a close button carrying data-dismiss.
|
|
59
|
+
public function get_nestable_children() {
|
|
60
|
+
return array(
|
|
61
|
+
array( 'name' => 'block', 'label' => esc_html__( 'Content', 'bricks' ) ),
|
|
62
|
+
array(
|
|
63
|
+
'name' => 'text-basic',
|
|
64
|
+
'label' => esc_html__( 'Close (×)', 'bricks' ),
|
|
65
|
+
'settings' => array(
|
|
66
|
+
'text' => '×',
|
|
67
|
+
'_attributes' => array(
|
|
68
|
+
array( 'id' => 'vdismiss', 'name' => 'data-dismiss', 'value' => '' ),
|
|
69
|
+
array( 'id' => 'vdismisslbl', 'name' => 'aria-label', 'value' => 'Dismiss' ),
|
|
70
|
+
),
|
|
71
|
+
),
|
|
72
|
+
),
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public function render() {
|
|
77
|
+
$s = $this->settings;
|
|
78
|
+
$attrs = array();
|
|
79
|
+
|
|
80
|
+
if ( isset( $s['duration'] ) && '' !== $s['duration'] ) {
|
|
81
|
+
$attrs[] = 'duration="' . esc_attr( $s['duration'] ) . '"';
|
|
82
|
+
}
|
|
83
|
+
if ( isset( $s['exit'] ) && '' !== $s['exit'] ) {
|
|
84
|
+
$attrs[] = 'exit="' . esc_attr( $s['exit'] ) . '"';
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
$attr_str = implode( ' ', $attrs );
|
|
88
|
+
|
|
89
|
+
echo "<wc-dismissable {$attr_str} {$this->render_attributes( '_root' )}>";
|
|
90
|
+
echo \Bricks\Frontend::render_children( $this );
|
|
91
|
+
echo '</wc-dismissable>';
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Vitops — Entries element (Bricks Builder).
|
|
4
|
+
*
|
|
5
|
+
* Renders the <wc-entries> Lit component (src/web-components/WCEntries.ts): an adaptive
|
|
6
|
+
* data display that enhances a series of heading + <dl> pairs into a table / column
|
|
7
|
+
* projection based on container width. Without JS the heading + <dl> pairs render
|
|
8
|
+
* stacked (semantic), so the builder canvas stays functional.
|
|
9
|
+
*
|
|
10
|
+
* Slotted content structure (add via Code / HTML children):
|
|
11
|
+
* <h3>Group title</h3>
|
|
12
|
+
* <dl><dt>Label</dt><dd>Value</dd> …</dl>
|
|
13
|
+
* (repeat)
|
|
14
|
+
*
|
|
15
|
+
* Owned by the framework repo (vitops: bricks/elements/); copied into the theme's
|
|
16
|
+
* dist/bricks/ on build — do not hand-edit in the theme.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
if ( ! defined( 'ABSPATH' ) ) {
|
|
20
|
+
exit;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
class Vitops_Element_Entries extends \Bricks\Element {
|
|
24
|
+
public $category = 'vitops';
|
|
25
|
+
public $name = 'vitops-entries';
|
|
26
|
+
public $icon = 'ti-layout-list-thumb';
|
|
27
|
+
public $css_selector = 'wc-entries';
|
|
28
|
+
public $nestable = true;
|
|
29
|
+
public $vue_component = 'bricks-nestable';
|
|
30
|
+
|
|
31
|
+
public function get_label() {
|
|
32
|
+
return esc_html__( 'Entries', 'bricks' );
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public function get_keywords() {
|
|
36
|
+
return array( 'entries', 'data', 'table', 'definition', 'list', 'dl', 'vitops' );
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public function set_controls() {
|
|
40
|
+
$this->controls['breakpoint'] = array(
|
|
41
|
+
'tab' => 'content',
|
|
42
|
+
'label' => esc_html__( 'Breakpoint', 'bricks' ),
|
|
43
|
+
'type' => 'text',
|
|
44
|
+
'placeholder' => '40rem',
|
|
45
|
+
'description' => esc_html__( 'Container width below which the projected/table view engages.', 'bricks' ),
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
$this->controls['projection'] = array(
|
|
49
|
+
'tab' => 'content',
|
|
50
|
+
'label' => esc_html__( 'Column projection (table)', 'bricks' ),
|
|
51
|
+
'type' => 'checkbox',
|
|
52
|
+
'description' => esc_html__( 'Project heading + <dl> pairs into a table.', 'bricks' ),
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
$this->controls['singular'] = array(
|
|
56
|
+
'tab' => 'content',
|
|
57
|
+
'label' => esc_html__( 'Singular (one row at a time)', 'bricks' ),
|
|
58
|
+
'type' => 'checkbox',
|
|
59
|
+
'description' => esc_html__( 'With projection + narrow: show one row with nav.', 'bricks' ),
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
$this->controls['structureInfo'] = array(
|
|
63
|
+
'tab' => 'content',
|
|
64
|
+
'type' => 'info',
|
|
65
|
+
'content' => esc_html__( 'Add children as heading + <dl> pairs: an <h3> group title followed by a <dl> of <dt>Label</dt><dd>Value</dd> pairs. Use a Code / HTML element for the <dl>.', 'bricks' ),
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Seed a heading so the structure is discoverable; the author adds the <dl>.
|
|
70
|
+
public function get_nestable_children() {
|
|
71
|
+
return array(
|
|
72
|
+
array( 'name' => 'heading', 'label' => esc_html__( 'Group title', 'bricks' ) ),
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public function render() {
|
|
77
|
+
$s = $this->settings;
|
|
78
|
+
$attrs = array();
|
|
79
|
+
|
|
80
|
+
if ( ! empty( $s['breakpoint'] ) ) {
|
|
81
|
+
$attrs[] = 'breakpoint="' . esc_attr( $s['breakpoint'] ) . '"';
|
|
82
|
+
}
|
|
83
|
+
if ( ! empty( $s['projection'] ) ) {
|
|
84
|
+
$attrs[] = 'projection';
|
|
85
|
+
}
|
|
86
|
+
if ( ! empty( $s['singular'] ) ) {
|
|
87
|
+
$attrs[] = 'singular';
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
$attr_str = implode( ' ', $attrs );
|
|
91
|
+
|
|
92
|
+
echo "<wc-entries {$attr_str} {$this->render_attributes( '_root' )}>";
|
|
93
|
+
echo \Bricks\Frontend::render_children( $this );
|
|
94
|
+
echo '</wc-entries>';
|
|
95
|
+
}
|
|
96
|
+
}
|