Skip to content

Commit 9c5f57d

Browse files
committed
docs: dashboard example of custom pages and the custom Vue skill switch columns by container width instead of screen width AdminForth/2005
1 parent 8a750bb commit 9c5f57d

3 files changed

Lines changed: 19 additions & 11 deletions

File tree

‎adminforth/commands/createApp/templates/.agents/skills/adminforth-custom-vue/SKILL.md.hbs‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ not wait for a follow-up prompt about styling or dark mode.
5151
8. **Never build Tailwind class names dynamically.** `custom/` is copied into the SPA sources and scanned
5252
statically by Tailwind, so `` `text-${color}-600` `` produces no CSS. Write full class strings and pick
5353
between them.
54+
9. **Layouts follow their container, not the screen.** The sidebar and the agent panel take part of the
55+
screen, so a page or panel which splits into columns is a Tailwind size container: `@container` on its
56+
root and `@md:`, `@4xl:` variants on the grid instead of `md:`, `lg:`. Give the grid `grid-cols-1` as its
57+
base, otherwise a wide chart or table stretches the single column past the page.
5458

5559
## Dark Theme Self-Check
5660

@@ -121,9 +125,11 @@ custom/
121125
122126
```vue
123127
<template>
124-
<section class="grid gap-4 md:grid-cols-2">
125-
<OrdersTotals :record="record" />
126-
<OrdersFilters :meta="meta" />
128+
<section class="@container">
129+
<div class="grid grid-cols-1 gap-4 @2xl:grid-cols-2">
130+
<OrdersTotals :record="record" />
131+
<OrdersFilters :meta="meta" />
132+
</div>
127133
</section>
128134
</template>
129135

‎adminforth/design/system-concepts.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Below `sm` (640px) a Dialog or Modal docks to the bottom edge as a sheet: full w
3535

3636
## Container width, not viewport width
3737

38-
A page gets less than the screen: the sidebar and the agent panel squeeze it on wide screens too. Layouts which stack follow their container with Tailwind container queries (`@container` on the parent, `@4xl:` on children), not the viewport with `md:` or `lg:`.
38+
A page gets less than the screen: the sidebar and the agent panel squeeze it on wide screens too. Layouts which stack follow their container with Tailwind container queries (`@container` on the parent, `@4xl:` on children), not the viewport with `md:` or `lg:`. Such a grid gets `grid-cols-1` as its base, otherwise a wide chart or table stretches its single column past the page.
3939

4040
The header of the list page is a container named `header`. Below 896px (`@4xl/header`) components from `beforeActionButtons` take a full row under the title and the buttons, from 896px all share one row. Below 512px (`@lg/header`) Home and Filter keep only their icons. Such a component fills its row and takes a fixed width from `@4xl/header:`, like the fields of quick-filters. Bulk actions of checked rows take a row of their own above the table, so the buttons next to the title never move.
4141

‎documentation/docs/tutorial/03-Customization/06-customPages.md‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ Create a Vue component in the `custom` directory of your project, e.g. `Dashboar
1414

1515
```html title="./custom/Dashboard.vue"
1616
<template>
17-
<div class="px-4 py-4 bg-blue-50 dark:bg-gray-900 dark:shadow-none min-h-screen">
17+
<div class="@container px-4 py-4 bg-blue-50 dark:bg-gray-900 dark:shadow-none min-h-screen">
1818

19-
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
20-
<div class="w-full bg-white rounded-lg shadow dark:bg-gray-800 p-4 md:p-5 min-h-[340px]" v-if="data">
19+
<div class="grid grid-cols-1 @xl:grid-cols-2 @4xl:grid-cols-3 @6xl:grid-cols-4 gap-4">
20+
<div class="w-full bg-white rounded-lg shadow dark:bg-gray-800 p-4 @xl:p-5 min-h-[340px]" v-if="data">
2121
<div class="mb-2">
2222
<h5 class="leading-none text-3xl font-bold text-gray-900 dark:text-white pb-2">{{ data.totalAparts }}</h5>
2323
<p class="text-base font-normal text-gray-500 dark:text-gray-400">{{ $t('Apartment last 7 days | Apartments last 7 days', data.totalAparts) }}</p>
@@ -44,7 +44,7 @@ Create a Vue component in the `custom` directory of your project, e.g. `Dashboar
4444
/>
4545
</div>
4646

47-
<div class="w-full bg-white rounded-lg shadow dark:bg-gray-800 p-4 md:p-5 min-h-[340px]" v-if="data">
47+
<div class="w-full bg-white rounded-lg shadow dark:bg-gray-800 p-4 @xl:p-5 min-h-[340px]" v-if="data">
4848
<p class="text-base font-normal text-gray-500 dark:text-gray-400 mb-3 text-center">
4949
{{ $t('Top countries') }}
5050
</p>
@@ -69,7 +69,7 @@ Create a Vue component in the `custom` directory of your project, e.g. `Dashboar
6969
</div>
7070
</div>
7171

72-
<div class="w-full bg-white rounded-lg shadow dark:bg-gray-800 p-4 md:p-5 lg:row-span-2 xl:col-span-2 min-h-[700px]" v-if="data">
72+
<div class="w-full bg-white rounded-lg shadow dark:bg-gray-800 p-4 @xl:p-5 @4xl:row-span-2 @6xl:col-span-2 min-h-[700px]" v-if="data">
7373
<div class="grid grid-cols-2 py-3 gap-4 text-center">
7474
<dl>
7575
<dt class="text-base font-normal text-gray-500 dark:text-gray-400 pb-1">
@@ -130,7 +130,7 @@ Create a Vue component in the `custom` directory of your project, e.g. `Dashboar
130130

131131
</div>
132132

133-
<div class="w-full bg-white rounded-lg shadow dark:bg-gray-800 p-4 md:p-5 min-h-[340px]" v-if="data">
133+
<div class="w-full bg-white rounded-lg shadow dark:bg-gray-800 p-4 @xl:p-5 min-h-[340px]" v-if="data">
134134
<p class="text-base font-normal text-gray-500 dark:text-gray-400 mb-3 text-center">{{ $t('Apartment by rooms') }}</p>
135135
<div class="flex justify-center items-center">
136136
<PieChart
@@ -155,7 +155,7 @@ Create a Vue component in the `custom` directory of your project, e.g. `Dashboar
155155
</div>
156156
</div>
157157

158-
<div class="w-full bg-white rounded-lg shadow dark:bg-gray-800 p-4 md:p-5 min-h-[340px]" v-if="data">
158+
<div class="w-full bg-white rounded-lg shadow dark:bg-gray-800 p-4 @xl:p-5 min-h-[340px]" v-if="data">
159159
<p class="text-base font-normal text-gray-500 dark:text-gray-400 mb-3 text-center">{{ $t('Unlisted vs Listed price' ) }}</p>
160160

161161
<AreaChart
@@ -269,6 +269,8 @@ onMounted(async () => {
269269
</script>
270270
```
271271
272+
> ☝️ The grid follows the width of the page content, not of the screen: the sidebar and the agent panel take part of it. `@container` on the root makes it a size container, `@xl:`, `@4xl:` and `@6xl:` switch the columns by its width.
273+
272274
> ☝️ use https://flowbite.com/ to get pre-designed tailwind design blocks for your pages
273275
274276
Now let's add this page to the AdminForth menu and make it homepage instead of Apartments page:

0 commit comments

Comments
 (0)