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
Lines changed: 28 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 7 additions & 7 deletions
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
Lines changed: 56 additions & 0 deletions
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+
```
Lines changed: 3 additions & 10 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 7 additions & 5 deletions
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) {

0 commit comments

Comments
 (0)