diff --git a/front/src/components/audio/track/Row.vue b/front/src/components/audio/track/Row.vue index 073b0c0c4..2cde48cda 100644 --- a/front/src/components/audio/track/Row.vue +++ b/front/src/components/audio/track/Row.vue @@ -9,7 +9,6 @@ import usePlayOptions from '~/composables/audio/usePlayOptions' import TrackFavoriteIcon from '~/components/favorites/TrackFavoriteIcon.vue' import PlayIndicator from '~/components/audio/track/PlayIndicator.vue' import PlayButton from '~/components/audio/PlayButton.vue' -import Button from '~/components/ui/Button.vue' import { usePlayer } from '~/composables/audio/player' import { useQueue } from '~/composables/audio/queue' import { useStore } from '~/store' @@ -65,13 +64,16 @@ const hover = ref(false) + + diff --git a/front/src/components/audio/track/Table.vue b/front/src/components/audio/track/Table.vue index eb71829fa..2e4e0fe33 100644 --- a/front/src/components/audio/track/Table.vue +++ b/front/src/components/audio/track/Table.vue @@ -16,6 +16,7 @@ import TrackRow from '~/components/audio/track/Row.vue' import Input from '~/components/ui/Input.vue' import Spacer from '~/components/ui/Spacer.vue' import Loader from '~/components/ui/Loader.vue' +import Table from '~/components/ui/Table.vue' import useErrorHandler from '~/composables/useErrorHandler' @@ -150,7 +151,9 @@ const updatePage = (page: number) => { + + diff --git a/front/src/components/ui/Layout.vue b/front/src/components/ui/Layout.vue index 8c1bd4243..5c4db11f3 100644 --- a/front/src/components/ui/Layout.vue +++ b/front/src/components/ui/Layout.vue @@ -90,6 +90,11 @@ const attributes = computed(() => ({ place-content: center; } + &[layout=grid], &[layout=grid-custom] > * { + /* Set this global variable through `width` */ + grid-column: var(--grid-column); + } + &[layout=stack] { display: flex; flex-direction: column; diff --git a/front/src/components/ui/Table.vue b/front/src/components/ui/Table.vue new file mode 100644 index 000000000..60e4c10cc --- /dev/null +++ b/front/src/components/ui/Table.vue @@ -0,0 +1,61 @@ + + + + + diff --git a/front/src/composables/width.ts b/front/src/composables/width.ts index 7d63c1f64..a178e6e35 100644 --- a/front/src/composables/width.ts +++ b/front/src/composables/width.ts @@ -20,18 +20,18 @@ export type Key = KeysOfUnion const widths = { minContent: 'width: min-content; flex-grow: 0;', iconWidth: 'width: 40px;', - tiny: "width: 124px; grid-column: span 2;", - buttonWidth: "width: 136px; grid-column: span 2; flex-grow: 0; min-width: min-content;", - small: "width: 202px; grid-column: span 3;", - medium: "width: 280px; grid-column: span 4;", + tiny: "width: 124px; --grid-column: span 2;", + buttonWidth: "width: 136px; --grid-column: span 2; flex-grow: 0; min-width: min-content;", + small: "width: 202px; --grid-column: span 3;", + medium: "width: 280px; --grid-column: span 4;", auto: "width: auto;", - full: "width: auto; grid-column: 1 / -1; place-self: stretch; flex-grow: 1;", + full: "width: auto; --grid-column: 1 / -1; place-self: stretch; flex-grow: 1;", width: (w: string) => `width: ${w}; flex-grow:0;`, } as const const sizes = { - squareSmall: 'height: 40px; width: 40px; padding: 4px; grid-column: span 1; justify-content: center;', - square: 'height: 48px; width: 48px; grid-column: span 1; justify-content: center;', + squareSmall: 'height: 40px; width: 40px; padding: 4px; justify-content: center;', + square: 'height: 48px; width: 48px; justify-content: center;', lowHeight: 'height: 40px;', normalHeight: 'height: 48px;', } as const diff --git a/front/ui-docs/.vitepress/config.ts b/front/ui-docs/.vitepress/config.ts index 0f3707bc7..1655b35c1 100644 --- a/front/ui-docs/.vitepress/config.ts +++ b/front/ui-docs/.vitepress/config.ts @@ -55,6 +55,7 @@ export default defineConfig({ { text: "Spacer", link: "/components/ui/layout/spacer" }, { text: "Header", link: "/components/ui/layout/header" }, { text: "Section", link: "/components/ui/layout/section" }, + { text: "Table", link: "/components/ui/layout/table" }, { text: "Using `flex`", link: "/components/ui/layout/flex" }, { text: "Using `stack`", link: "/components/ui/layout/stack" }, { text: "Using `grid`", link: "/components/ui/layout/grid" }, diff --git a/front/ui-docs/components/ui/layout.md b/front/ui-docs/components/ui/layout.md index eeebbc0d1..6cf9ee386 100644 --- a/front/ui-docs/components/ui/layout.md +++ b/front/ui-docs/components/ui/layout.md @@ -192,39 +192,3 @@ Note that you can set the minimum space occupied by the `Spacer` with its `size` - ---- - - - - -Items are laid out in a row and wrapped as they overflow the container - -[Layout flex](/components/ui/layout/flex) - - - - -Align items both vertically and horizontally - -[Layout grid](/components/ui/layout/grid) - - - - - -Add space between vertically stacked items - -[Layout stack](/components/ui/layout/stack) - - - - - -Let text and items flow like on a printed newspaper - -[Layout columns](/components/ui/layout/columns) - - - - diff --git a/front/ui-docs/components/ui/layout/table.md b/front/ui-docs/components/ui/layout/table.md new file mode 100644 index 000000000..fca0db67f --- /dev/null +++ b/front/ui-docs/components/ui/layout/table.md @@ -0,0 +1,211 @@ + + +```ts +import Table from "~/components/ui/Table.vue"; +``` + +# Table + +Arrange cells in a grid. + +For every row, add exactly one element per column. + + + Design [Penpot] + + +**Prop** `grid-template-columns`: An array of the column widths. You can make a column either fixed-width or use part of the available space: + +- `100px`: Exactly this width +- `auto`: The the widest cell in the column +- `1fr`: A certain fraction of the remaining space + +The whole table always has a width of 100% (or `stretch`, if inside a flex or grid context). If the minimum sizes don't fit, all cells will shrink proportionally. + +```vue-html + + 100px + auto + 2fr + 1fr +
+``` + + + 100px + auto + 2fr + 1fr +
+ +## Add a table header + +Use the `#header` slot to add items to the header. Make sure to add one item per column. + +```vue-html + + + + +
+``` + + + + + +
+ +## Let cells span multiple rows or columns + +- Cells automatically expand into the **next column** if the following item is empty. Make sure the first element in each row is not empty! +- You can let elements span **multiple rows** by adding `style=grid-row: span 3`. In this case, you have to remove the corresponding cells directly below. + +```vue-html + + + + +
 
+
C1
+
Title 1
+
+
Artist 1
+
+
D1
+
+ + +
B2
+
C2
+
Title 2
+
Album 2
+
Artist 2
+
F2
+
D2
+
+ + +
B3
+
C3
+
Title 3
+
Artist 3
+
F3
+
D3
+
+ + +
B4
+
C4
+
Title 4
+
+
+
F4
+
D4
+
+
+``` + + + + + +
 
+
C1
+
Title 1
+
+
Artist 1
+
+
D1
+
+ + +
B2
+
C2
+
Title 2
+
Album 2
+
Artist 2
+
F2
+
D2
+
+ + +
B3
+
C3
+
Title 3
+
Artist 3
+
F3
+
D3
+
+ + +
B4
+
C4
+
Title 4
+
+
+
F4
+
D4
+
+
+ +## Add props to the table header + +To add class names and other properties to the table header, set the `header-props` prop. In the following example, the whole header section is made inert. + +Note that `style` properties may not have an effect because the header section is `display: contents`. Instead, add a custom attribute and add scoped style rule targeting your attribute. + +```vue-html + + +
+``` + + + +