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

fix: use theme background as default #151

Merged
merged 1 commit into from
Apr 11, 2022
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
2 changes: 1 addition & 1 deletion public/static/css/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
}

.theme-dark #bg {
/* background: url("/static/img/textured_paper.png") repeat fixed center; */
background: url("/static/img/px_by_Gre3g.webp") repeat fixed center;
background-color: rgb(22 22 24);
color: #ccc;
position: fixed;
Expand Down
30 changes: 16 additions & 14 deletions src/client/web/src/components/root_frame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,22 @@ export class RootFrame extends React.Component<Props, State, {}> {
}

makeBgStyle = (): Object => {
if (
this.props.login.preferences != null &&
this.props.login.preferences.bg.url !== ""
) {
const bgConfig = this.props.login.preferences.bg;
return {
background: `url("${bgConfig.url}") ${bgConfig.repeat} ${bgConfig.position} ${bgConfig.align}`,
};
}

if (this.props.login.preferences.bg.bgColor !== "") {
return {
backgroundColor: this.props.login.preferences.bg.bgColor,
};
if (this.props.ui.clientCfg.allowSetBg) {
if (
this.props.login.preferences != null &&
this.props.login.preferences.bg.url !== ""
) {
const bgConfig = this.props.login.preferences.bg;
return {
background: `url("${bgConfig.url}") ${bgConfig.repeat} ${bgConfig.position} ${bgConfig.align}`,
};
}

if (this.props.login.preferences.bg.bgColor !== "") {
return {
backgroundColor: this.props.login.preferences.bg.bgColor,
};
}
}

if (this.props.ui.clientCfg.bg.url !== "") {
Expand Down
12 changes: 2 additions & 10 deletions src/db/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ var (
DefaultSiteName = "Quickshare"
DefaultSiteDesc = "Quickshare"
DefaultBgConfig = &BgConfig{
Url: "",
Repeat: "repeat",
Position: "top",
Align: "fixed",
BgColor: "#ccc",
BgColor: "",
}
DefaultAllowSetBg = false
DefaultAutoTheme = true
Expand Down Expand Up @@ -266,12 +267,6 @@ func CheckPreferences(prefers *Preferences, fillDefault bool) error {
}

func CheckBgConfig(cfg *BgConfig, fillDefault bool) error {
if cfg.Url == "" && cfg.BgColor == "" {
if !fillDefault {
return errors.New("one of Bg.Url or Bg.BgColor must be defined")
}
cfg.BgColor = DefaultBgConfig.BgColor
}
if !BgRepeatValues[cfg.Repeat] {
return fmt.Errorf("invalid repeat value (%s)", cfg.Repeat)
}
Expand All @@ -291,9 +286,6 @@ func CheckBgConfig(cfg *BgConfig, fillDefault bool) error {
if cfg.Align == "" {
cfg.Align = DefaultBgConfig.Align
}
if cfg.BgColor == "" {
cfg.BgColor = DefaultBgConfig.BgColor
}
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions src/server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ func DefaultConfigStruct() *Config {
SiteName: "Quickshare",
SiteDesc: "Quick and simple file sharing",
Bg: &db.BgConfig{
Url: "/static/img/textured_paper.png",
Url: "",
Repeat: "repeat",
Position: "center",
Align: "fixed",
BgColor: "#ccc",
BgColor: "",
},
AllowSetBg: false,
AutoTheme: true,
Expand Down
4 changes: 2 additions & 2 deletions src/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ func initDeps(cfg gocfg.ICfg) *depidx.Deps {
SiteName: cfg.StringOr("Site.ClientCfg.SiteName", "Quickshare"),
SiteDesc: cfg.StringOr("Site.ClientCfg.SiteDesc", "Quick and simple file sharing"),
Bg: &db.BgConfig{
Url: cfg.StringOr("Site.ClientCfg.Bg.Url", "/static/img/textured_paper.png"),
Url: cfg.StringOr("Site.ClientCfg.Bg.Url", ""),
Repeat: cfg.StringOr("Site.ClientCfg.Bg.Repeat", "repeat"),
Position: cfg.StringOr("Site.ClientCfg.Bg.Position", "center"),
Align: cfg.StringOr("Site.ClientCfg.Bg.Align", "fixed"),
BgColor: cfg.StringOr("Site.ClientCfg.Bg.BgColor", "#ccc"),
BgColor: cfg.StringOr("Site.ClientCfg.Bg.BgColor", ""),
},
},
})
Expand Down