Skip to content

Commit

Permalink
tmp: settings for header styling
Browse files Browse the repository at this point in the history
  • Loading branch information
kaljarv authored and gogarufi committed Oct 20, 2024
1 parent 84cb7a9 commit 16abbfe
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
"repeatable": false,
"component": "settings.entities",
"required": true
},
"headerStyle": {
"type": "component",
"repeatable": false,
"component": "settings.header-style"
}
}
}
15 changes: 15 additions & 0 deletions backend/vaa-strapi/src/components/settings/header-style-dark.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"collectionName": "components_settings_header_style_darks",
"info": {
"displayName": "Header Style - Dark"
},
"options": {},
"attributes": {
"bgColor": {
"type": "string"
},
"overImgBgColor": {
"type": "string"
}
}
}
15 changes: 15 additions & 0 deletions backend/vaa-strapi/src/components/settings/header-style-light.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"collectionName": "components_settings_header_style_lights",
"info": {
"displayName": "Header Style - Light"
},
"options": {},
"attributes": {
"bgColor": {
"type": "string"
},
"overImgBgColor": {
"type": "string"
}
}
}
27 changes: 27 additions & 0 deletions backend/vaa-strapi/src/components/settings/header-style.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"collectionName": "components_settings_header_styles",
"info": {
"displayName": "Header Style"
},
"options": {},
"attributes": {
"dark": {
"displayName": "Header Style - Dark",
"type": "component",
"repeatable": false,
"component": "settings.header-style-dark"
},
"light": {
"displayName": "Header Style - Light",
"type": "component",
"repeatable": false,
"component": "settings.header-style-light"
},
"imgSize": {
"type": "string"
},
"imgPosition": {
"type": "string"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"name": "Apache 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
},
"x-generation-date": "2024-10-08T10:22:54.399Z"
"x-generation-date": "2024-10-20T07:50:50.713Z"
},
"x-strapi-config": {
"path": "/documentation",
Expand Down Expand Up @@ -3948,6 +3948,9 @@
"entities": {
"$ref": "#/components/schemas/SettingsEntitiesComponent"
},
"headerStyle": {
"$ref": "#/components/schemas/SettingsHeaderStyleComponent"
},
"createdAt": {
"type": "string",
"format": "date-time"
Expand Down Expand Up @@ -4497,6 +4500,48 @@
}
}
},
"SettingsHeaderStyleComponent": {
"type": "object",
"properties": {
"id": {
"type": "number"
},
"dark": {
"type": "object",
"properties": {
"id": {
"type": "number"
},
"bgColor": {
"type": "string"
},
"overImgBgColor": {
"type": "string"
}
}
},
"light": {
"type": "object",
"properties": {
"id": {
"type": "number"
},
"bgColor": {
"type": "string"
},
"overImgBgColor": {
"type": "string"
}
}
},
"imgSize": {
"type": "string"
},
"imgPosition": {
"type": "string"
}
}
},
"CandidateRequest": {
"type": "object",
"required": [
Expand Down
12 changes: 7 additions & 5 deletions frontend/src/lib/api/dataProvider/strapi/strapiDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,18 @@ function getData<T extends object>(
*/
function getAppSettings(): Promise<Partial<AppSettings> | undefined> {
const params = new URLSearchParams({
'populate[header]': 'true',
'populate[matching]': 'true',
'populate[survey]': 'true',
'populate[entities][populate][hideIfMissingAnswers]': 'true',
'populate[entityDetails][populate][contents]': 'true',
'populate[entityDetails][populate][showMissingElectionSymbol]': 'true',
'populate[entityDetails][populate][showMissingAnswers]': 'true',
'populate[entityDetails][populate][showMissingElectionSymbol]': 'true',
'populate[header]': 'true',
'populate[headerStyle][populate][dark]': 'true',
'populate[headerStyle][populate][light]': 'true',
'populate[matching]': 'true',
'populate[questions][populate][categoryIntros]': 'true',
'populate[questions][populate][questionsIntro]': 'true',
'populate[results][populate][cardContents]': 'true'
'populate[results][populate][cardContents]': 'true',
'populate[survey]': 'true'
});
return getData<StrapiAppSettingsData[]>('api/app-settings', params)
.then((result) => {
Expand Down
22 changes: 11 additions & 11 deletions frontend/src/lib/api/dataProvider/strapi/strapiDataProvider.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,18 @@ export interface StrapiAppSettingsData {
header?: {
showFeedback: boolean;
showHelp: boolean;
topBar: {
dark: {
bgColor?: string;
overImgBgColor?: string;
};
light: {
bgColor?: string;
overImgBgColor?: string;
};
imgSize?: string;
imagePosition?: string;
};
headerStyle?: {
dark: {
bgColor?: string;
overImgBgColor?: string;
};
light: {
bgColor?: string;
overImgBgColor?: string;
};
imgSize?: string;
imgPosition?: string;
};
matching?: {
minimumAnswers: number;
Expand Down
19 changes: 9 additions & 10 deletions frontend/src/routes/[[lang=locale]]/(voters)/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@
const topBar = getTopBarContext();
const topBarAppSettings = $settings.header.topBar;
const topBarNoImgBgColor = $darkMode
? topBarAppSettings.dark.bgColor
: topBarAppSettings.light.bgColor;
const topBarOverImgBgColor = $darkMode
? topBarAppSettings.dark.overImgBgColor
: topBarAppSettings.light.overImgBgColor;
const topBarBgColor = $topBar.imageSrc ? topBarOverImgBgColor : topBarNoImgBgColor;
const topBarAppSettings = $settings.headerStyle;
let bgColor: string | undefined;
$: {
const mode = $darkMode ? topBarAppSettings.dark : topBarAppSettings.light;
bgColor = $topBar.imageSrc ? mode.overImgBgColor : mode.bgColor;
}
const progress = getTopBarProgressContext();
const currentProgress = progress.current;
Expand All @@ -49,7 +48,7 @@
class:top-bar={!$topBar.imageSrc}
style:--image={$topBar.imageSrc && `url(${$topBar.imageSrc})`}
style:--background-size={$topBar.imageSrc && topBarAppSettings.imgSize}
style:--background-position={$topBar.imageSrc && topBarAppSettings.imagePosition}>
style:--background-position={$topBar.imageSrc && topBarAppSettings.imgPosition}>
{#if !$topBar.hideProgressBar}
<progress
class="progress progress-primary absolute left-0 top-0 h-2"
Expand All @@ -59,7 +58,7 @@
{/if}
<div
class="inner-actions-bar flex w-full items-center justify-between pr-6"
style:--background-color={topBarBgColor}>
style:--background-color={bgColor}>
<button
on:click={openDrawer}
bind:this={drawerOpenElement}
Expand Down
20 changes: 10 additions & 10 deletions shared/src/settings/dynamicSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ export const dynamicSettings: DynamicSettings = {
header: {
showFeedback: true,
showHelp: true,
topBar: {
dark: {
overImgBgColor: "transparent"
},
light: {
overImgBgColor: "transparent",
},
imgSize: "cover",
imagePosition: "center"
}
},
headerStyle: {
dark: {
overImgBgColor: "transparent"
},
light: {
overImgBgColor: "transparent",
},
imgSize: "cover",
imgPosition: "center"
},
entities: {
hideIfMissingAnswers: {
Expand Down
24 changes: 12 additions & 12 deletions shared/src/settings/settings.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,19 +190,19 @@ export type DynamicSettings = {
* Whether to show the help icon by default in the header.
*/
showHelp: boolean;
topBar: {
dark: {
bgColor?: string;
overImgBgColor?: string;
},
light: {
bgColor?: string;
overImgBgColor?: string;
}
imgSize?: string;
imagePosition?: string;
}
};
headerStyle: {
dark: {
bgColor?: string;
overImgBgColor?: string;
},
light: {
bgColor?: string;
overImgBgColor?: string;
}
imgSize?: string;
imgPosition?: string;
}
/**
* Settings controlling which entities are shown in the app.
*/
Expand Down

0 comments on commit 16abbfe

Please sign in to comment.