Skip to content

Commit 7a3bc3d

Browse files
author
Alexander
authored
feat!: ability to change the application grid (#49) (#91)
1 parent 4162c8a commit 7a3bc3d

File tree

7 files changed

+81
-4
lines changed

7 files changed

+81
-4
lines changed

Diff for: docs/reference/configuration.md

+21
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,27 @@ tags:
9898
More details can be found in the [tags](../reference/tags.md) section.
9999
:::
100100

101+
## Layout <in-version value="0.14.0" />
102+
103+
A group of parameters responsible for the application layout.
104+
105+
### Grid
106+
107+
Allows you to set the number of columns at different screen resolutions.
108+
109+
```yaml
110+
layout:
111+
grid:
112+
small: 2
113+
medium: 2
114+
large: 3
115+
xlarge: 4
116+
```
117+
118+
Values: range `1 - 12`
119+
120+
You can only specify one value, the others will be set automatically.
121+
101122
## Services
102123

103124
All services that are displayed on the home page are set in this parameter.

Diff for: docs/ru/reference/configuration.md

+21
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,27 @@ tags:
9898
Более подробно о тегах можно прочитать в [разделе](../reference/tags.md).
9999
:::
100100

101+
## Макет <in-version value="0.14.0" />
102+
103+
Группа параметров отвечающих за макет приложения.
104+
105+
### Сетка
106+
107+
Позволяет настроить количество колонок на разных разрешениях экрана.
108+
109+
```yaml
110+
layout:
111+
grid:
112+
small: 2
113+
medium: 2
114+
large: 3
115+
xlarge: 4
116+
```
117+
118+
Поддерживаемые значения: диапазон `1 - 12`
119+
120+
Вы можете указать только одно значение, остальные будут установлены автоматически.
121+
101122
## Сервисы
102123

103124
Все сервисы, которые отображаются на главной странице задаются в данном параметре.

Diff for: src/components/Group.vue

+16-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<h2 v-if="title" class="text-2xl font-light py-2 px-4">
44
{{ title }}
55
</h2>
6-
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-1 lg:gap-2 lg:gap-y-4">
6+
<div :class="gridClasses">
77
<template v-for="item in items" :key="item.id">
88
<Item v-bind="item" />
99
</template>
@@ -12,12 +12,25 @@
1212
</template>
1313

1414
<script setup lang="ts">
15-
import type { Service } from '~/types'
15+
import type { Layout, Service } from '~/types'
1616
1717
export interface Props {
1818
title?: string
1919
items: Service[]
20+
grid: Layout['grid']
2021
}
2122
22-
defineProps<Props>()
23+
const props = defineProps<Props>()
24+
25+
const gridClasses = computed(() => [
26+
'grid',
27+
'grid-cols-1',
28+
`sm:grid-cols-${props.grid.small}`,
29+
`md:grid-cols-${props.grid.medium}`,
30+
`lg:grid-cols-${props.grid.large}`,
31+
`xl:grid-cols-${props.grid.xlarge}`,
32+
'gap-1',
33+
'lg:gap-2',
34+
'lg:gap-y-4',
35+
])
2336
</script>

Diff for: src/pages/index.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Group
33
v-for="(group, key) in $services"
44
:key="key"
5-
v-bind="group"
5+
v-bind="{ ...group, grid: $settings.layout.grid }"
66
/>
77
<Update v-if="$settings.checkUpdates" />
88
</template>

Diff for: src/server/utils/config.ts

+8
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ export function getDefaultConfig(): CompleteConfig {
3636
lang: 'en',
3737
theme: 'system',
3838
checkUpdates: true,
39+
layout: {
40+
grid: {
41+
small: 2,
42+
medium: 2,
43+
large: 3,
44+
xlarge: 4,
45+
},
46+
},
3947
behaviour: {
4048
target: '_blank',
4149
},

Diff for: src/types/config.d.ts

+10
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,20 @@ export interface Behaviour {
1414
target?: '_blank' | '_self' | '_parent' | '_top'
1515
}
1616

17+
export interface Layout {
18+
grid: {
19+
small: number
20+
medium: number
21+
large: number
22+
xlarge: number
23+
}
24+
}
25+
1726
export interface Config {
1827
title?: string
1928
lang: 'en' | 'ru'
2029
theme?: 'system' | 'light' | 'dark' | 'deep' | 'sepia'
30+
layout?: Layout
2131
behaviour?: Behaviour
2232
tags: Tag[]
2333
services: ServicesGroup[]

Diff for: tailwind.config.ts

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ export default <Partial<Config>>{
77
pattern: /(bg|text)-./,
88
variants: ['dark'],
99
},
10+
{
11+
pattern: /grid-cols-./,
12+
variants: ['sm', 'md', 'lg', 'xl'],
13+
},
1014
],
1115
theme: {
1216
extend: {

0 commit comments

Comments
 (0)