Skip to content

Commit efb1de6

Browse files
authored
Merge pull request #5405 from Jakoma02/submit-to-community-library-panel
Submit to Community Library panel
2 parents fdcff2e + 86bd2fc commit efb1de6

File tree

18 files changed

+2213
-560
lines changed

18 files changed

+2213
-560
lines changed
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
<template>
2+
3+
<div class="box">
4+
<KTransition kind="component-fade-out-in">
5+
<div
6+
v-if="loading"
7+
key="box-loader-wrapper"
8+
class="loader-wrapper"
9+
>
10+
<KCircularLoader disableDefaultTransition />
11+
</div>
12+
<div
13+
v-else
14+
key="box-content"
15+
class="box-content"
16+
>
17+
<div class="box-icon">
18+
<KIcon :icon="icon" />
19+
</div>
20+
<slot></slot>
21+
<div
22+
v-if="$slots.chip"
23+
class="chip"
24+
>
25+
<slot name="chip"></slot>
26+
</div>
27+
</div>
28+
</KTransition>
29+
</div>
30+
31+
</template>
32+
33+
34+
<script>
35+
36+
import { computed } from 'vue';
37+
import { themePalette, themeTokens } from 'kolibri-design-system/lib/styles/theme';
38+
39+
export default {
40+
name: 'Box',
41+
setup(props) {
42+
const paletteTheme = themePalette();
43+
const tokensTheme = themeTokens();
44+
45+
const boxBackgroundColor = computed(() => {
46+
switch (props.kind) {
47+
case 'warning':
48+
return paletteTheme.yellow.v_100;
49+
case 'info':
50+
return paletteTheme.grey.v_100;
51+
default:
52+
throw new Error(`Unsupported box kind: ${props.kind}`);
53+
}
54+
});
55+
const boxTextColor = computed(() => {
56+
switch (props.kind) {
57+
case 'warning':
58+
return paletteTheme.red.v_500;
59+
case 'info':
60+
return tokensTheme.text;
61+
default:
62+
throw new Error(`Unsupported box kind: ${props.kind}`);
63+
}
64+
});
65+
const icon = computed(() => {
66+
switch (props.kind) {
67+
case 'warning':
68+
return 'warningIncomplete';
69+
case 'info':
70+
return 'infoOutline';
71+
default:
72+
throw new Error(`Unsupported box kind: ${props.kind}`);
73+
}
74+
});
75+
76+
return {
77+
boxBackgroundColor,
78+
boxTextColor,
79+
icon,
80+
};
81+
},
82+
props: {
83+
kind: {
84+
type: String,
85+
required: false,
86+
default: 'info',
87+
validator: value => ['warning', 'info'].includes(value),
88+
},
89+
loading: {
90+
type: Boolean,
91+
required: false,
92+
default: false,
93+
},
94+
},
95+
};
96+
97+
</script>
98+
99+
100+
<style lang="scss" scoped>
101+
102+
.box {
103+
padding: 8px;
104+
color: v-bind('boxTextColor');
105+
background-color: v-bind('boxBackgroundColor');
106+
border-radius: 4px;
107+
}
108+
109+
.box-content {
110+
display: flex;
111+
gap: 8px;
112+
}
113+
114+
.box-icon {
115+
width: 20px;
116+
height: 20px;
117+
}
118+
119+
.chip {
120+
margin-left: auto;
121+
}
122+
123+
.loader-wrapper {
124+
display: flex;
125+
flex: 1;
126+
align-items: center;
127+
justify-content: center;
128+
}
129+
130+
</style>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<template>
2+
3+
<div v-if="!omitted">
4+
<div
5+
v-if="loading"
6+
class="loader-wrapper"
7+
>
8+
<KCircularLoader :size="16" />
9+
{{ $tr('checking') }}
10+
</div>
11+
<div v-else-if="finishedLoading">
12+
<slot></slot>
13+
</div>
14+
<div v-else>{{ $tr('error') }}</div>
15+
</div>
16+
<div v-else><KEmptyPlaceholder /></div>
17+
18+
</template>
19+
20+
21+
<script setup>
22+
23+
defineProps({
24+
loading: {
25+
type: Boolean,
26+
required: true,
27+
},
28+
finishedLoading: {
29+
type: Boolean,
30+
required: true,
31+
},
32+
omitted: {
33+
type: Boolean,
34+
required: false,
35+
default: false,
36+
},
37+
});
38+
39+
</script>
40+
41+
42+
<script>
43+
44+
export default {
45+
$trs: {
46+
checking: 'Checking...',
47+
error: 'Error loading data.',
48+
},
49+
};
50+
51+
</script>
52+
53+
54+
<style scoped lang="scss">
55+
56+
.loader-wrapper {
57+
display: flex;
58+
gap: 8px;
59+
align-items: center;
60+
}
61+
62+
.loader-wrapper ::v-deep .ui-progress-circular {
63+
display: inline-block;
64+
margin: 0;
65+
}
66+
67+
</style>
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<template>
2+
3+
<div class="status-chip">
4+
<KIcon
5+
:icon="icon"
6+
:color="labelColor"
7+
class="status-icon"
8+
/>
9+
{{ text }}
10+
</div>
11+
12+
</template>
13+
14+
15+
<script>
16+
17+
import { themePalette } from 'kolibri-design-system/lib/styles/theme';
18+
import { computed } from 'vue';
19+
import { communityChannelsStrings } from 'shared/strings/communityChannelsStrings';
20+
import { CommunityLibraryStatus } from 'shared/constants';
21+
22+
export default {
23+
name: 'StatusChip',
24+
setup(props) {
25+
const theme = themePalette();
26+
27+
const { pendingStatus$, approvedStatus$, flaggedStatus$ } = communityChannelsStrings;
28+
29+
const configChoices = {
30+
[CommunityLibraryStatus.PENDING]: {
31+
text: pendingStatus$(),
32+
color: theme.yellow.v_100,
33+
labelColor: theme.orange.v_600,
34+
icon: 'schedule',
35+
},
36+
[CommunityLibraryStatus.APPROVED]: {
37+
text: approvedStatus$(),
38+
color: theme.green.v_100,
39+
labelColor: theme.green.v_600,
40+
icon: 'circleCheckmark',
41+
},
42+
[CommunityLibraryStatus.REJECTED]: {
43+
text: flaggedStatus$(),
44+
color: theme.red.v_100,
45+
labelColor: theme.red.v_600,
46+
icon: 'error',
47+
},
48+
};
49+
50+
const icon = computed(() => configChoices[props.status].icon);
51+
const text = computed(() => configChoices[props.status].text);
52+
const color = computed(() => configChoices[props.status].color);
53+
const labelColor = computed(() => configChoices[props.status].labelColor);
54+
55+
return {
56+
icon,
57+
text,
58+
color,
59+
labelColor,
60+
};
61+
},
62+
props: {
63+
status: {
64+
type: String,
65+
required: true,
66+
validator: value =>
67+
[
68+
CommunityLibraryStatus.APPROVED,
69+
CommunityLibraryStatus.PENDING,
70+
CommunityLibraryStatus.REJECTED,
71+
].includes(value),
72+
},
73+
},
74+
};
75+
76+
</script>
77+
78+
79+
<style lang="css" scoped>
80+
81+
.status-chip {
82+
display: flex;
83+
gap: 3px;
84+
align-items: center;
85+
height: 20px;
86+
padding-top: 2px;
87+
padding-right: 5px;
88+
padding-bottom: 2px;
89+
padding-left: 3px;
90+
font-size: 12px;
91+
font-weight: 400;
92+
color: v-bind('labelColor');
93+
background-color: v-bind('color');
94+
border-radius: 16px;
95+
}
96+
97+
.status-icon {
98+
position: static;
99+
width: 18px;
100+
height: 18px;
101+
}
102+
103+
</style>

0 commit comments

Comments
 (0)