Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add customization for dark-mode logo #411

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions public/assets/images/move.svg

This file was deleted.

12 changes: 12 additions & 0 deletions public/assets/images/peace-in-a-box-white.svg
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could easily change the fill color from the outside of SVG images via CSS Custom Properties.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/assets/images/peace-in-a-box.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 51 additions & 18 deletions src/components/Customization/LogoUpload/logo-upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "./index.scss";
import { getThemeImage } from "../../../utils";
import Upload from "../Upload";
import { useTranslation } from "react-i18next";
import { DBDivider, DBInfotext } from "@db-ui/react-components";

const LogoUpload = memo(() => {
const { t } = useTranslation();
Expand All @@ -12,24 +13,56 @@ const LogoUpload = memo(() => {
return (
<div className="flex flex-col gap-fix-md">
<h5>{t("logo")}</h5>
<div className="flex gap-fix-md justify-between">
<img
className="logo"
src={getThemeImage(defaultTheme.image)}
alt="logo"
/>
<Upload
label="uploadLogo"
accept="image/*"
onUpload={(result) => {
useThemeBuilderStore.setState({
defaultTheme: {
...defaultTheme,
image: result,
},
});
}}
/>
<div className="flex gap-fix-md">
<div
className="flex flex-col gap-fix-md p-fix-sm"
data-color-scheme="light"
>
<DBInfotext icon="day">Light</DBInfotext>
<img
className="h-siz-md mx-auto"
src={getThemeImage(defaultTheme.image)}
alt="logo"
/>
<Upload
size="small"
label="uploadLogo"
accept="image/*"
onUpload={(result) => {
useThemeBuilderStore.setState({
defaultTheme: {
...defaultTheme,
image: result,
},
});
}}
/>
</div>
<DBDivider margin="none" variant="vertical" />
<div
className="flex flex-col gap-fix-md p-fix-sm"
data-color-scheme="dark"
>
<DBInfotext icon="night">Dark</DBInfotext>
<img
className="h-siz-md mx-auto"
src={getThemeImage(defaultTheme.imageDark || defaultTheme.image)}
alt="logo"
/>
<Upload
size="small"
label="uploadLogo"
accept="image/*"
onUpload={(result) => {
useThemeBuilderStore.setState({
defaultTheme: {
...defaultTheme,
imageDark: result,
},
});
}}
/>
</div>
</div>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions src/components/Customization/Upload/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export type UploadPropsType = {
label: string;
accept?: string;
onUpload: (result: string) => void;
size?: "small";
};
8 changes: 6 additions & 2 deletions src/components/Customization/Upload/upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ import "./index.scss";
import { useTranslation } from "react-i18next";
import { UploadPropsType } from "./data.ts";

const Upload = memo(({ label, accept, onUpload }: UploadPropsType) => {
const Upload = memo(({ label, accept, onUpload, size }: UploadPropsType) => {
const { t } = useTranslation();

return (
<label className="upload-button relative" data-icon="upload">
<label
className="upload-button relative"
data-icon="upload"
data-size={size}
>
{t(label)}
<input
type="file"
Expand Down
6 changes: 5 additions & 1 deletion src/components/DefaultPage/default-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ const DefaultPage = ({
<div className="db-brand">
<img
className="logo"
src={getThemeImage(defaultTheme.image)}
src={getThemeImage(
isDark() && defaultTheme.imageDark
? defaultTheme.imageDark
: defaultTheme.image,
)}
alt="brand"
/>
{name}
Expand Down
10 changes: 9 additions & 1 deletion src/components/Landing/Header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ const Header = () => {
return (
<div className="py-fix-xs px-fix-md md:py-fix-md">
<div className="flex justify-between min-h-siz-md">
<img className="logo" src={getThemeImage(defaultTheme.image)} alt="brand" />
<img
className="logo"
src={getThemeImage(
isDarkMode && defaultTheme.imageDark
? defaultTheme.imageDark
: defaultTheme.image,
)}
alt="brand"
/>
<a
href="https://github.com/db-ui/theme-builder"
target="_blank"
Expand Down
1 change: 1 addition & 0 deletions src/data/default-theme.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Default Theme",
"image": "peace-in-a-box.svg",
"imageDark": "peace-in-a-box-white.svg",
"spacing": {
"_scale": "100%",
"responsive": {
Expand Down
1 change: 1 addition & 0 deletions src/utils/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export type SizingFixedType = {
export type DefaultThemeType = {
name: string;
image: string;
imageDark: string;
spacing: {
responsive: ThemeTonalities;
fixed: ThemeTonalities;
Expand Down
Loading