Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Toolkit/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
- [Shadcn] Rework templates of `input-group` recipe
- [Shadcn] Rework templates of `table` recipe
- [Shadcn] Rework templates of `textarea` recipe
- [Shadcn] Add `Avatar:Badge` component
- [Shadcn] Add `Avatar:Fallback` component
- [Shadcn] Add `Avatar:Group` component
- [Shadcn] Add `Avatar:GroupCount` component
- [Shadcn] Add `Alert:Action` component
- [Shadcn] Remove `Avatar:Text` component

## 2.29.0

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<twig:Avatar:Group class="grayscale">
<twig:Avatar>
<twig:Avatar:Image src="https://github.com/shadcn.png" alt="@shadcn" />
<twig:Avatar:Fallback>CN</twig:Avatar:Fallback>
</twig:Avatar>
<twig:Avatar>
<twig:Avatar:Image src="https://github.com/maxleiter.png" alt="@maxleiter" />
<twig:Avatar:Fallback>LR</twig:Avatar:Fallback>
</twig:Avatar>
<twig:Avatar>
<twig:Avatar:Image src="https://github.com/evilrabbit.png" alt="@evilrabbit" />
<twig:Avatar:Fallback>ER</twig:Avatar:Fallback>
</twig:Avatar>
<twig:Avatar:GroupCount>+3</twig:Avatar:GroupCount>
</twig:Avatar:Group>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<twig:Avatar:Group class="grayscale">
<twig:Avatar>
<twig:Avatar:Image src="https://github.com/shadcn.png" alt="@shadcn" />
<twig:Avatar:Fallback>CN</twig:Avatar:Fallback>
</twig:Avatar>
<twig:Avatar>
<twig:Avatar:Image src="https://github.com/maxleiter.png" alt="@maxleiter" />
<twig:Avatar:Fallback>LR</twig:Avatar:Fallback>
</twig:Avatar>
<twig:Avatar>
<twig:Avatar:Image src="https://github.com/evilrabbit.png" alt="@evilrabbit" />
<twig:Avatar:Fallback>ER</twig:Avatar:Fallback>
</twig:Avatar>
<twig:Avatar:GroupCount>
<twig:ux:icon name="lucide:plus" />
</twig:Avatar:GroupCount>
</twig:Avatar:Group>
14 changes: 14 additions & 0 deletions src/Toolkit/kits/shadcn/avatar/examples/Avatar Group.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<twig:Avatar:Group class="grayscale">
<twig:Avatar>
<twig:Avatar:Image src="https://github.com/shadcn.png" alt="@shadcn" />
<twig:Avatar:Fallback>CN</twig:Avatar:Fallback>
</twig:Avatar>
<twig:Avatar>
<twig:Avatar:Image src="https://github.com/maxleiter.png" alt="@maxleiter" />
<twig:Avatar:Fallback>LR</twig:Avatar:Fallback>
</twig:Avatar>
<twig:Avatar>
<twig:Avatar:Image src="https://github.com/evilrabbit.png" alt="@evilrabbit" />
<twig:Avatar:Fallback>ER</twig:Avatar:Fallback>
</twig:Avatar>
</twig:Avatar:Group>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<twig:Avatar>
<twig:Avatar:Image src="https://github.com/shadcn.png" alt="@shadcn" />
<twig:Avatar:Fallback>CN</twig:Avatar:Fallback>
<twig:Avatar:Badge>
<twig:ux:icon name="lucide:plus" />
</twig:Avatar:Badge>
</twig:Avatar>
5 changes: 5 additions & 0 deletions src/Toolkit/kits/shadcn/avatar/examples/Badge.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<twig:Avatar>
<twig:Avatar:Image src="https://github.com/shadcn.png" alt="@shadcn" />
<twig:Avatar:Fallback>CN</twig:Avatar:Fallback>
<twig:Avatar:Badge class="bg-green-600 dark:bg-green-800" />
</twig:Avatar>
8 changes: 8 additions & 0 deletions src/Toolkit/kits/shadcn/avatar/examples/Basic.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<twig:Avatar>
<twig:Avatar:Image
src="https://github.com/shadcn.png"
alt="@shadcn"
class="grayscale"
/>
<twig:Avatar:Fallback>CN</twig:Avatar:Fallback>
</twig:Avatar>
31 changes: 20 additions & 11 deletions src/Toolkit/kits/shadcn/avatar/examples/Demo.html.twig
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
<div class="flex flex-row flex-wrap items-center gap-12">
<div class="grid w-full max-w-xl items-start gap-4">
<twig:Avatar>
<twig:Avatar:Image src="https://avatars.githubusercontent.com/u/47313?v=4" alt="Fabien Potencier" />
<twig:Avatar:Image
src="https://github.com/shadcn.png"
alt="@shadcn"
class="grayscale"
/>
<twig:Avatar:Fallback>CN</twig:Avatar:Fallback>
</twig:Avatar>

<twig:Avatar class="rounded-lg">
<twig:Avatar:Image src="https://avatars.githubusercontent.com/u/47313?v=4" alt="Fabien Potencier" />
<twig:Avatar>
<twig:Avatar:Image src="https://github.com/evilrabbit.png" alt="@evilrabbit" />
<twig:Avatar:Fallback>ER</twig:Avatar:Fallback>
<twig:Avatar:Badge class="bg-green-600 dark:bg-green-800" />
</twig:Avatar>

<div class="*:data-[slot=avatar]:ring-background flex -space-x-2 *:data-[slot=avatar]:ring-2">
<twig:Avatar:Group class="grayscale">
<twig:Avatar>
<twig:Avatar:Text class="bg-red-200">A</twig:Avatar:Text>
<twig:Avatar:Image src="https://github.com/shadcn.png" alt="@shadcn" />
<twig:Avatar:Fallback>CN</twig:Avatar:Fallback>
</twig:Avatar>
<twig:Avatar>
<twig:Avatar:Text class="bg-red-300">B</twig:Avatar:Text>
<twig:Avatar:Image src="https://github.com/maxleiter.png" alt="@maxleiter" />
<twig:Avatar:Fallback>LR</twig:Avatar:Fallback>
</twig:Avatar>
<twig:Avatar>
<twig:Avatar:Text class="bg-red-400">C</twig:Avatar:Text>
<twig:Avatar:Image src="https://github.com/evilrabbit.png" alt="@evilrabbit" />
<twig:Avatar:Fallback>ER</twig:Avatar:Fallback>
</twig:Avatar>
</div>
<twig:Avatar:GroupCount>+3</twig:Avatar:GroupCount>
</twig:Avatar:Group>
</div>
14 changes: 14 additions & 0 deletions src/Toolkit/kits/shadcn/avatar/examples/Sizes.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div class="flex flex-wrap items-center gap-2 grayscale">
<twig:Avatar size="sm">
<twig:Avatar:Image src="https://github.com/shadcn.png" alt="@shadcn" />
<twig:Avatar:Fallback>CN</twig:Avatar:Fallback>
</twig:Avatar>
<twig:Avatar>
<twig:Avatar:Image src="https://github.com/shadcn.png" alt="@shadcn" />
<twig:Avatar:Fallback>CN</twig:Avatar:Fallback>
</twig:Avatar>
<twig:Avatar size="lg">
<twig:Avatar:Image src="https://github.com/shadcn.png" alt="@shadcn" />
<twig:Avatar:Fallback>CN</twig:Avatar:Fallback>
</twig:Avatar>
</div>
7 changes: 2 additions & 5 deletions src/Toolkit/kits/shadcn/avatar/examples/Usage.html.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<twig:Avatar>
<twig:Avatar:Image src="https://avatars.githubusercontent.com/u/47313?v=4" alt="Fabien Potencier" />
</twig:Avatar>

<twig:Avatar>
<twig:Avatar:Text class="bg-red-200">FB</twig:Avatar:Text>
<twig:Avatar:Image src="https://github.com/shadcn.png" alt="@shadcn" />
<twig:Avatar:Fallback>CN</twig:Avatar:Fallback>
</twig:Avatar>
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{# @prop size 'default'|'sm'|'lg' The size, default to `default` #}
{# @block content The default block #}
{%- props size = 'default' -%}

<span
class="{{ 'relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full ' ~ attributes.render('class')|tailwind_merge }}"
data-slot="avatar"
data-size="{{ size }}"
class="{{ 'group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6 ' ~ attributes.render('class')|tailwind_merge }}"
{{ attributes }}
>
{%- block content %}{% endblock -%}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{# @block content The default block #}
{%- set classes = html_classes(
'bg-primary text-primary-foreground ring-background absolute right-0 bottom-0 z-10 inline-flex items-center justify-center rounded-full ring-2 select-none',
'group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden',
'group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2',
'group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2',
attributes.render('class')|default(''),
) -%}

<span
data-slot="avatar-badge"
class="{{ classes|tailwind_merge }}"
{{ attributes }}
>
{%- block content %}{% endblock -%}
</span>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{# @block content The default block #}
<span
data-slot="avatar-fallback"
class="{{ 'bg-muted text-muted-foreground flex size-full items-center justify-center rounded-full text-sm group-data-[size=sm]/avatar:text-xs ' ~ attributes.render('class')|tailwind_merge }}"
{{ attributes }}
>
{%- block content %}{% endblock -%}
</span>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{# @block content The default block #}
<div
data-slot="avatar-group"
class="{{ '*:data-[slot=avatar]:ring-background group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2 ' ~ attributes.render('class')|tailwind_merge }}"
{{ attributes }}
>
{%- block content %}{% endblock -%}
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{# @block content The default block #}
<div
data-slot="avatar-group-count"
class="{{ 'bg-muted text-muted-foreground ring-background relative flex size-8 shrink-0 items-center justify-center rounded-full text-sm ring-2 group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3 ' ~ attributes.render('class')|tailwind_merge }}"
{{ attributes }}
>
{%- block content %}{% endblock -%}
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<img
class="{{ 'aspect-square h-full w-full ' ~ attributes.render('class')|tailwind_merge }}"
data-slot="avatar-image"
class="{{ 'aspect-square size-full ' ~ attributes.render('class')|tailwind_merge }}"
{{ attributes.defaults({alt: ''}) }}
/>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<div class="*:data-[slot=avatar]:ring-background flex -space-x-2 *:data-[slot=avatar]:size-12 *:data-[slot=avatar]:ring-2 *:data-[slot=avatar]:grayscale">
<twig:Avatar>
<twig:Avatar:Image src="https://github.com/shadcn.png" alt="@shadcn" />
<twig:Avatar:Text>CN</twig:Avatar:Text>
<twig:Avatar:Fallback>CN</twig:Avatar:Fallback>
</twig:Avatar>
<twig:Avatar>
<twig:Avatar:Image src="https://github.com/maxleiter.png" alt="@maxleiter" />
<twig:Avatar:Text>LR</twig:Avatar:Text>
<twig:Avatar:Fallback>LR</twig:Avatar:Fallback>
</twig:Avatar>
<twig:Avatar>
<twig:Avatar:Image src="https://github.com/evilrabbit.png" alt="@evilrabbit" />
<twig:Avatar:Text>ER</twig:Avatar:Text>
<twig:Avatar:Fallback>ER</twig:Avatar:Fallback>
</twig:Avatar>
</div>
</twig:Empty:Media>
Expand Down
2 changes: 1 addition & 1 deletion src/Toolkit/kits/shadcn/empty/examples/Avatar.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
alt="@shadcn"
class="grayscale"
/>
<twig:Avatar:Text>LR</twig:Avatar:Text>
<twig:Avatar:Fallback>LR</twig:Avatar:Fallback>
</twig:Avatar>
</twig:Empty:Media>
<twig:Empty:Title>User offline</twig:Empty:Title>
Expand Down
8 changes: 4 additions & 4 deletions src/Toolkit/kits/shadcn/item/examples/Avatar.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@

<twig:Item variant="outline">
<twig:Item:Media>
<div class="*:data-[slot=avatar]:ring-background flex -space-x-2 *:data-[slot=avatar]:ring-2">
<div class="*:data-[slot=avatar]:ring-background flex -space-x-2 *:data-[slot=avatar]:ring-2 *:data-[slot=avatar]:grayscale">
<twig:Avatar class="hidden sm:flex">
<twig:Avatar:Text class="bg-red-200">A</twig:Avatar:Text>
<twig:Avatar:Fallback class="bg-red-200">A</twig:Avatar:Fallback>
</twig:Avatar>
<twig:Avatar class="hidden sm:flex">
<twig:Avatar:Text class="bg-red-300">B</twig:Avatar:Text>
<twig:Avatar:Fallback class="bg-red-300">B</twig:Avatar:Fallback>
</twig:Avatar>
<twig:Avatar class="hidden sm:flex">
<twig:Avatar:Text class="bg-red-400">C</twig:Avatar:Text>
<twig:Avatar:Fallback class="bg-red-400">C</twig:Avatar:Fallback>
</twig:Avatar>
</div>
</twig:Item:Media>
Expand Down
5 changes: 4 additions & 1 deletion src/Toolkit/tests/Command/DebugKitCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ public function testShouldBeAbleToDebugShadcnKit()
->assertOutputContains(implode(\PHP_EOL, [
'+--------------+------------------------ Recipe: "avatar" ----------------------------------------+',
'| File(s) | templates/components/Avatar.html.twig |',
'| | templates/components/Avatar/Badge.html.twig |',
'| | templates/components/Avatar/Fallback.html.twig |',
'| | templates/components/Avatar/Group.html.twig |',
'| | templates/components/Avatar/GroupCount.html.twig |',
'| | templates/components/Avatar/Image.html.twig |',
'| | templates/components/Avatar/Text.html.twig |',
'| Dependencies | tales-from-a-dev/twig-tailwind-extra:^1.0.0 |',
'+--------------+----------------------------------------------------------------------------------+',
]))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!--
- Kit: Shadcn UI
- Component: Avatar
- Code:
```twig
<twig:Avatar:Group class="grayscale">
<twig:Avatar>
<twig:Avatar:Image src="https://github.com/shadcn.png" alt="@shadcn" />
<twig:Avatar:Fallback>CN</twig:Avatar:Fallback>
</twig:Avatar>
<twig:Avatar>
<twig:Avatar:Image src="https://github.com/maxleiter.png" alt="@maxleiter" />
<twig:Avatar:Fallback>LR</twig:Avatar:Fallback>
</twig:Avatar>
<twig:Avatar>
<twig:Avatar:Image src="https://github.com/evilrabbit.png" alt="@evilrabbit" />
<twig:Avatar:Fallback>ER</twig:Avatar:Fallback>
</twig:Avatar>
<twig:Avatar:GroupCount>+3</twig:Avatar:GroupCount>
</twig:Avatar:Group>
```
- Rendered code (prettified for testing purposes, run "php vendor/bin/phpunit -d --update-snapshots" to update snapshots): -->
<div data-slot="avatar-group" class="*:data-[slot=avatar]:ring-background group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2 grayscale">
<span data-slot="avatar" data-size="default" class="group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6 "><img data-slot="avatar-image" class="aspect-square size-full " alt="@shadcn" src="https://github.com/shadcn.png">

<span data-slot="avatar-fallback" class="bg-muted text-muted-foreground flex size-full items-center justify-center rounded-full text-sm group-data-[size=sm]/avatar:text-xs ">CN</span>
</span>
<span data-slot="avatar" data-size="default" class="group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6 "><img data-slot="avatar-image" class="aspect-square size-full " alt="@maxleiter" src="https://github.com/maxleiter.png">

<span data-slot="avatar-fallback" class="bg-muted text-muted-foreground flex size-full items-center justify-center rounded-full text-sm group-data-[size=sm]/avatar:text-xs ">LR</span>
</span>
<span data-slot="avatar" data-size="default" class="group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6 "><img data-slot="avatar-image" class="aspect-square size-full " alt="@evilrabbit" src="https://github.com/evilrabbit.png">

<span data-slot="avatar-fallback" class="bg-muted text-muted-foreground flex size-full items-center justify-center rounded-full text-sm group-data-[size=sm]/avatar:text-xs ">ER</span>
</span>
<div data-slot="avatar-group-count" class="bg-muted text-muted-foreground ring-background relative flex size-8 shrink-0 items-center justify-center rounded-full text-sm ring-2 group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&amp;&gt;svg]:size-4 group-has-data-[size=lg]/avatar-group:[&amp;&gt;svg]:size-5 group-has-data-[size=sm]/avatar-group:[&amp;&gt;svg]:size-3 ">+3</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!--
- Kit: Shadcn UI
- Component: Avatar
- Code:
```twig
<twig:Avatar:Group class="grayscale">
<twig:Avatar>
<twig:Avatar:Image src="https://github.com/shadcn.png" alt="@shadcn" />
<twig:Avatar:Fallback>CN</twig:Avatar:Fallback>
</twig:Avatar>
<twig:Avatar>
<twig:Avatar:Image src="https://github.com/maxleiter.png" alt="@maxleiter" />
<twig:Avatar:Fallback>LR</twig:Avatar:Fallback>
</twig:Avatar>
<twig:Avatar>
<twig:Avatar:Image src="https://github.com/evilrabbit.png" alt="@evilrabbit" />
<twig:Avatar:Fallback>ER</twig:Avatar:Fallback>
</twig:Avatar>
<twig:Avatar:GroupCount>
<twig:ux:icon name="lucide:plus" />
</twig:Avatar:GroupCount>
</twig:Avatar:Group>
```
- Rendered code (prettified for testing purposes, run "php vendor/bin/phpunit -d --update-snapshots" to update snapshots): -->
<div data-slot="avatar-group" class="*:data-[slot=avatar]:ring-background group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2 grayscale">
<span data-slot="avatar" data-size="default" class="group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6 "><img data-slot="avatar-image" class="aspect-square size-full " alt="@shadcn" src="https://github.com/shadcn.png">

<span data-slot="avatar-fallback" class="bg-muted text-muted-foreground flex size-full items-center justify-center rounded-full text-sm group-data-[size=sm]/avatar:text-xs ">CN</span>
</span>
<span data-slot="avatar" data-size="default" class="group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6 "><img data-slot="avatar-image" class="aspect-square size-full " alt="@maxleiter" src="https://github.com/maxleiter.png">

<span data-slot="avatar-fallback" class="bg-muted text-muted-foreground flex size-full items-center justify-center rounded-full text-sm group-data-[size=sm]/avatar:text-xs ">LR</span>
</span>
<span data-slot="avatar" data-size="default" class="group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6 "><img data-slot="avatar-image" class="aspect-square size-full " alt="@evilrabbit" src="https://github.com/evilrabbit.png">

<span data-slot="avatar-fallback" class="bg-muted text-muted-foreground flex size-full items-center justify-center rounded-full text-sm group-data-[size=sm]/avatar:text-xs ">ER</span>
</span>
<div data-slot="avatar-group-count" class="bg-muted text-muted-foreground ring-background relative flex size-8 shrink-0 items-center justify-center rounded-full text-sm ring-2 group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&amp;&gt;svg]:size-4 group-has-data-[size=lg]/avatar-group:[&amp;&gt;svg]:size-5 group-has-data-[size=sm]/avatar-group:[&amp;&gt;svg]:size-3 ">
<svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24" fill="currentColor" aria-hidden="true"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h14m-7-7v14"></path></svg>
</div>
</div>
Loading
Loading