Skip to content

Commit 8895b81

Browse files
committed
[Toolkit] Rework the documentation
1 parent 6c0de75 commit 8895b81

File tree

102 files changed

+1429
-1421
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+1429
-1421
lines changed
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Toolkit Kits
2+
3+
on:
4+
push:
5+
paths:
6+
- 'src/Toolkit/kits/**'
7+
pull_request:
8+
paths:
9+
- 'src/Toolkit/kits/**'
10+
11+
jobs:
12+
kits-cs:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: shivammathur/setup-php@v2
18+
with:
19+
php-version: 8.3
20+
21+
- name: Install composer packages
22+
uses: ramsey/composer-install@v3
23+
with:
24+
working-directory: src/Toolkit
25+
26+
- name: Check kits code style
27+
run: php vendor/bin/twig-cs-fixer check kits
28+
working-directory: src/Toolkit

src/Toolkit/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "symfony/ux-toolkit",
33
"type": "symfony-bundle",
4-
"description": "Twig Toolkit for Symfony",
4+
"description": "A tool for easily creating your own design system in your Symfony app, by installing well-crafted and fully-customizable Twig components",
55
"keywords": [
66
"symfony-ux",
77
"twig",

src/Toolkit/doc/index.rst

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ to change, or even change drastically.
77
Symfony UX Toolkit provides a set of ready-to-use kits for Symfony applications.
88
It is part of `the Symfony UX initiative`_.
99

10-
Kits are a nice way to begin a new Symfony application, by providing a set
10+
Kits are a nice way to begin a new Symfony application, by providing a set
1111
of `Twig components`_ (based on Tailwind CSS, but fully customizable depending
1212
on your needs).
1313

@@ -24,8 +24,8 @@ Additionally, some `Twig components`_ use ``html_cva`` and ``tailwind_merge``,
2424
you can either remove them from your project or install ``twig/html-extra``
2525
and ``tales-from-a-dev/twig-tailwind-extra`` to use them.
2626

27-
Also, we do not force you to use Tailwind CSS at all. If you want to use
28-
another CSS framework, you can, but you will need to adapt the UI components to it.
27+
Also, we do not force you to use Tailwind CSS at all. You can use whatever
28+
CSS framework you want, but you will need to adapt the UI components to it.
2929

3030
Installation
3131
------------
@@ -37,7 +37,7 @@ Install the UX Toolkit using Composer and Symfony Flex:
3737
# The UX Toolkit is a development dependency:
3838
$ composer require --dev symfony/ux-toolkit
3939
40-
# If you want to keep `html_cva` and `tailwind_merge` in your UI components:
40+
# If you want to keep `html_cva` and `tailwind_merge` in your Twig components:
4141
$ composer require twig/extra-bundle twig/html-extra:^3.12.0 tales-from-a-dev/twig-tailwind-extra
4242
4343
Configuration
@@ -71,7 +71,7 @@ It will create the ``templates/components/Button.html.twig`` file, and you will
7171
Create your own kit
7272
-------------------
7373

74-
You have the ability to create and share your own kit with the community,
74+
You have the ability to create and share your own kit with the community,
7575
by using the ``php vendor/bin/ux-toolkit-kit-create`` command in a new GitHub repository:
7676

7777
.. code-block:: terminal
@@ -89,7 +89,7 @@ by using the ``php vendor/bin/ux-toolkit-kit-create`` command in a new GitHub re
8989
9090
# Create your kit
9191
$ php vendor/bin/ux-toolkit-kit-create
92-
92+
9393
# ... edit the files, add your components, examples, etc.
9494
9595
# Share your kit
@@ -124,7 +124,7 @@ A kit is composed of:
124124
Use your kit in a Symfony application
125125
-------------------------------------
126126

127-
You can globally configure the kit to use in your application by setting the ``ux_toolkit.kit`` parameter:
127+
You can globally configure the kit to use in your application by setting the ``ux_toolkit.kit`` configuration:
128128

129129
.. code-block:: yaml
130130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Input
2+
3+
A form input component for text, email, password, and other input types.
4+
5+
```twig {"preview":true}
6+
<twig:Input type="email" placeholder="Email" class="max-w-sm" />
7+
```
8+
9+
## Installation
10+
11+
<!-- Placeholder: Installation -->
12+
13+
## Usage
14+
15+
<!-- Placeholder: Usage -->
16+
17+
## Examples
18+
19+
### Default
20+
21+
```twig {"preview":true}
22+
<twig:Input type="email" placeholder="Email" class="max-w-sm" />
23+
```
24+
25+
### File
26+
27+
```twig {"preview":true}
28+
<div class="grid w-full max-w-sm items-center gap-1.5">
29+
<label for="picture">Picture</label>
30+
<twig:Input type="file" id="picture" />
31+
</div>
32+
```
33+
34+
### Disabled
35+
36+
```twig {"preview":true}
37+
<twig:Input type="email" placeholder="Email" disabled class="max-w-sm" />
38+
```
39+
40+
### With Label
41+
42+
```twig {"preview":true}
43+
<div class="grid w-full max-w-sm items-center gap-1.5">
44+
<twig:Label for="email">Email</twig:Label>
45+
<twig:Input type="email" id="email" />
46+
</div>
47+
```
48+
49+
### With Button
50+
51+
```twig {"preview":true}
52+
<div class="flex w-full max-w-sm items-center space-x-2">
53+
<twig:Input type="email" id="email" />
54+
<twig:Button type="submit">Subscribe</twig:Button>
55+
</div>
56+
```
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
{%- props -%}
2-
{%- set style = html_cva(
3-
base: 'aspect-square h-full w-full',
4-
variants: {},
5-
compoundVariants: []
6-
) -%}
7-
81
<img
9-
class="{{ style.apply({}, attributes.render('class'))|tailwind_merge }}"
10-
{{ attributes.defaults({}).without('class') }}
11-
/>
2+
class="{{ 'aspect-square h-full w-full ' ~ attributes.render('class')|tailwind_merge }}"
3+
{{ attributes.defaults({alt: ''}).without('class') }}
4+
/>

src/Toolkit/src/Kit/KitFactory.php

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\Filesystem\Filesystem;
1515
use Symfony\Component\Filesystem\Path;
1616
use Symfony\Component\Finder\Finder;
17-
use Symfony\Component\Yaml\Yaml;
1817
use Symfony\UX\Toolkit\Component\Component;
1918
use Symfony\UX\Toolkit\Dependency\DependenciesResolver;
2019
use Symfony\UX\Toolkit\File\Doc;

src/Toolkit/tests/Kit/KitFactoryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function testCanCreateKit(): void
6868
6969
A component for displaying structured data in rows and columns with support for headers, captions, and customizable styling.
7070
EOF
71-
, $table->doc->markdownContent);
71+
, $table->doc->markdownContent);
7272
}
7373

7474
private function createKitFactory(): KitFactory

ux.symfony.com/.platform.app.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ hooks:
5353
export NO_NPM=1
5454
5555
(>&2 symfony-build)
56+
php bin/console tailwind:build --minify
57+
php bin/console asset-map:compile
5658
5759
deploy: |
5860
set -x -e

ux.symfony.com/.symfony.local.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ workers:
22
docker_compose: ~
33
sass:
44
cmd: ['symfony', 'console', 'sass:build', '--watch']
5+
tailwind:
6+
cmd: ['symfony', 'console', 'tailwind:build', '--watch']
57

68
http:
79
use_gzip: true

ux.symfony.com/assets/controllers/tabs-controller.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import {Controller} from '@hotwired/stimulus';
2-
import {getComponent} from '@symfony/ux-live-component';
1+
import { Controller } from '@hotwired/stimulus';
2+
import { getComponent } from '@symfony/ux-live-component';
33

44
export default class extends Controller {
55
static targets = ["tab", "control"]
6-
static values = {tab: String}
7-
static classes = [ "active" ]
6+
static values = { tab: String }
7+
static classes = ["active"]
88

99
initialize() {
1010
this.showTab(this.tabValue);
1111
}
1212

13-
show({ params: { tab }}) {
13+
show({ params: { tab } }) {
1414
this.tabValue = tab;
1515
}
1616

@@ -20,6 +20,7 @@ export default class extends Controller {
2020

2121
const controlTarget = this.getControlTarget(tab);
2222
controlTarget.classList.add(this.activeClass);
23+
controlTarget.setAttribute("aria-selected", "true");
2324
}
2425

2526
hideTab(tab) {
@@ -28,6 +29,7 @@ export default class extends Controller {
2829

2930
const controlTarget = this.getControlTarget(tab);
3031
controlTarget.classList.remove(this.activeClass);
32+
controlTarget.setAttribute("aria-selected", "false");
3133
}
3234

3335
tabValueChanged(value, previousValue) {
Loading
Loading
Loading

ux.symfony.com/assets/styles/app.scss

+5-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ $utilities: map-remove(
7575
// @import "../../vendor/twbs/bootstrap/scss/navbar";
7676
@import "../../vendor/twbs/bootstrap/scss/card";
7777
// @import "../../vendor/twbs/bootstrap/scss/accordion";
78-
// @import "../../vendor/twbs/bootstrap/scss/breadcrumb";
78+
@import "../../vendor/twbs/bootstrap/scss/breadcrumb";
7979
// @import "../../vendor/twbs/bootstrap/scss/pagination";
8080
// @import "../../vendor/twbs/bootstrap/scss/badge";
8181
@import "../../vendor/twbs/bootstrap/scss/alert";
@@ -128,6 +128,7 @@ $utilities: map-remove(
128128
@import "components/Button";
129129
@import "components/Browser";
130130
@import "components/Changelog";
131+
@import "components/CodePreview_Tabs";
131132
@import "components/DataList";
132133
@import "components/DemoContainer";
133134
@import "components/DemoCard";
@@ -144,15 +145,18 @@ $utilities: map-remove(
144145
@import "components/PackageHeader";
145146
@import "components/PackageBox";
146147
@import "components/PackageList";
148+
@import "components/SidebarNav";
147149
@import "components/Cookbook";
148150
@import "components/SupportBox";
149151
@import "components/Tabs";
150152
@import "components/Tag";
151153
@import "components/Terminal";
152154
@import "components/TerminalCommand";
153155
@import "components/ThemeSwitcher";
156+
@import "components/Wysiwyg";
154157

155158
// Utilities
159+
@import "utilities/animation";
156160
@import "utilities/arrow";
157161
@import "utilities/background";
158162
@import "utilities/info-tooltips";
@@ -176,4 +180,3 @@ $utilities: map-remove(
176180
.code-description a {
177181
text-decoration: underline;
178182
}
179-
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
.CodePreview_Tabs {
2+
}
3+
4+
.CodePreview_TabHead {
5+
display: flex;
6+
flex-direction: row;
7+
margin-bottom: 1rem
8+
}
9+
10+
.CodePreview_TabControl {
11+
border-bottom: 3px solid transparent;
12+
color: var(--bs-primary-color);
13+
padding: 0 1rem;
14+
font-size: .9rem;
15+
line-height: 2;
16+
font-stretch: semi-condensed;
17+
transition: border-color 150ms ease-in-out;
18+
margin-bottom: -1px;
19+
}
20+
21+
.CodePreview_TabControl.active {
22+
border-color: var(--bs-secondary-color);
23+
}
24+
25+
.CodePreview_TabPanel {
26+
position: relative;
27+
}
28+
29+
.CodePreview_TabPanel:not(.active) {
30+
display: none;
31+
}
32+
33+
.CodePreview_TabPanel:has(.CodePreview_Preview) {
34+
border: 1px solid var(--bs-border-color);
35+
border-radius: .75rem
36+
}
37+
38+
.CodePreview_Loader {
39+
width: 100%;
40+
display: flex;
41+
justify-content: center;
42+
align-items: center;
43+
gap: .2rem;
44+
position: absolute;
45+
46+
svg {
47+
animation: rotating 1s linear infinite;
48+
}
49+
}
50+
51+
.CodePreview_Preview {
52+
width: 100%;
53+
transition: opacity .250s linear;
54+
border-radius: .75rem;
55+
opacity: 1;
56+
57+
&.loading {
58+
opacity: 0;
59+
}
60+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.SidebarNav {}
2+
3+
.SidebarNav_Heading {
4+
font-weight: 600;
5+
padding: 0 .5rem;
6+
}
7+
8+
.SidebarNav_Item {
9+
border-radius: .5rem;
10+
transition: background-color 100ms ease-in-out;
11+
}
12+
.SidebarNav_Item.active,
13+
.SidebarNav_Item:hover {
14+
background-color: var(--bs-secondary-bg);
15+
}
16+
17+
18+
.SidebarNav_Link {
19+
display: block;
20+
font-size: .9rem;
21+
padding: .1rem .5rem;
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.Wysiwyg {
2+
h1 {
3+
font-family: var(--font-family-title);
4+
font-size: 2.6rem;
5+
font-weight: 700;
6+
margin-bottom: 1rem;
7+
}
8+
9+
h2 {
10+
font-family: var(--font-family-title);
11+
font-size: 2rem;
12+
font-weight: 700;
13+
margin-bottom: 0.5rem;
14+
margin-top: 2rem;
15+
}
16+
17+
h3 {
18+
font-family: var(--font-family-title);
19+
font-size: 1.5rem;
20+
font-weight: 700;
21+
margin-bottom: 0.5rem;
22+
margin-top: 1.5rem;
23+
}
24+
25+
a {
26+
color: var(--bs-link-color);
27+
text-decoration: underline;
28+
}
29+
}

0 commit comments

Comments
 (0)