Skip to content

Commit

Permalink
feat: add dark mode on and chinese translation for web (#1765)
Browse files Browse the repository at this point in the history
* feat: add dark mode on ui

* chore: update description

* chore: update @verdaccio/ui-theme@1.5.0

* chore: add spaces
  • Loading branch information
juanpicado committed Apr 8, 2020
1 parent ef185fb commit 4a81262
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
7 changes: 7 additions & 0 deletions conf/default.yaml
Expand Up @@ -17,6 +17,13 @@ web:
# gravatar: false
# by default packages are ordercer ascendant (asc|desc)
# sort_packages: asc
# convert your UI to the dark side
# darkMode: true

# translate your registry, api i18n not available yet
# i18n:
# list of the available translations https://github.com/verdaccio/ui/tree/master/i18n/translations
# web: en-US

auth:
htpasswd:
Expand Down
6 changes: 6 additions & 0 deletions conf/docker.yaml
Expand Up @@ -23,6 +23,12 @@ web:
# gravatar: false
# by default packages are ordercer ascendant (asc|desc)
# sort_packages: asc
# darkMode: true

# translate your registry, api i18n not available yet
# i18n:
# list of the available translations https://github.com/verdaccio/ui/tree/master/i18n/translations
# web: en-US

auth:
htpasswd:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -24,7 +24,7 @@
"@verdaccio/local-storage": "^9.3.4",
"@verdaccio/readme": "^9.3.3",
"@verdaccio/streams": "^9.3.2",
"@verdaccio/ui-theme": "^1.0.0",
"@verdaccio/ui-theme": "^1.5.0",
"JSONStream": "1.3.5",
"async": "3.2.0",
"body-parser": "1.19.0",
Expand Down
18 changes: 16 additions & 2 deletions src/api/web/index.ts
Expand Up @@ -16,6 +16,8 @@ import loadPlugin from '../../lib/plugin-loader';
const { setSecurityWebHeaders } = require('../middleware');
const pkgJSON = require('../../../package.json');

const DEFAULT_LANGUAGE = 'es-US';

export function loadTheme(config) {
if (_.isNil(config.theme) === false) {
return _.head(
Expand Down Expand Up @@ -80,11 +82,23 @@ export default function(config, auth, storage) {
const { url_prefix } = config;
const uri = `${protocol}://${host}`;
const base = combineBaseUrl(protocol, host, url_prefix);
const languageWeb = config?.i18n?.web ?? 'es-US';
const language = config?.i18n?.web ?? DEFAULT_LANGUAGE;
const darkMode = config?.web?.darkMode ?? false;
const primaryColor = _.get(config, 'web.primary_color') ? config.web.primary_color : '';
const title = _.get(config, 'web.title') ? config.web.title : WEB_TITLE;
const scope = _.get(config, 'web.scope') ? config.web.scope : '';
const options = { uri, protocol, host, url_prefix, base, primaryColor, title, scope, language: languageWeb };
const options = {
uri,
darkMode,
protocol,
host,
url_prefix,
base,
primaryColor,
title,
scope,
language,
};

const webPage = template
.replace(/ToReplaceByVerdaccioUI/g, JSON.stringify(options))
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Expand Up @@ -1969,10 +1969,10 @@
resolved "https://registry.verdaccio.org/@verdaccio%2fui-theme/-/ui-theme-0.3.9.tgz#6ff0f05315912b4ba39e29eb589ecc8833640990"
integrity sha512-InTpEowYo6M9TjpQh4cVh/HZH1DW9oyhy8UpC1H4FOwvyknctN0dMavOseKWSrPAj+gPDzUw0IKAvwDI4OcPEg==

"@verdaccio/ui-theme@^1.0.0":
version "1.0.0"
resolved "https://registry.verdaccio.org/@verdaccio%2fui-theme/-/ui-theme-1.0.0.tgz#53706449fdb2e66e06a22867deb3efedf6ddc9d2"
integrity sha512-gUggtAV9lOa2SmhYZmRRd/AGR5HmZ+N3uGoXnZXVjPckTetE/fsB8mqkSYZCk0SrO767j82JGhyU8O/JVKM8jw==
"@verdaccio/ui-theme@^1.5.0":
version "1.5.0"
resolved "https://registry.verdaccio.org/@verdaccio%2fui-theme/-/ui-theme-1.5.0.tgz#748e2db1772106a4de64dbed1152e16cd4b34a7c"
integrity sha512-OLkTTJPnBgUDsRrGqIg5RC3NBmb7wolQEPrTGE1ScuVe0sO3351fw+TFj/hx5Oepbv4PqxknYossmWcrMaSq6Q==

"@yarnpkg/lockfile@^1.1.0":
version "1.1.0"
Expand Down

0 comments on commit 4a81262

Please sign in to comment.