Skip to content

Commit 6bc4f3e

Browse files
committed
feature: dark theme: add (#332)
1 parent 3562208 commit 6bc4f3e

23 files changed

+187
-52
lines changed

.webpack/css.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22

3+
const {env} = require('node:process');
34
const fs = require('node:fs');
45
const {
56
basename,
@@ -10,7 +11,6 @@ const {
1011
const ExtractTextPlugin = require('extract-text-webpack-plugin');
1112
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
1213

13-
const {env} = require('node:process');
1414
const isDev = env.NODE_ENV === 'development';
1515

1616
const extractCSS = (a) => new ExtractTextPlugin(`${a}.css`);
@@ -23,6 +23,7 @@ const cssNames = [
2323
'terminal',
2424
'user-menu',
2525
...getCSSList('columns'),
26+
...getCSSList('themes'),
2627
];
2728

2829
const cssPlugins = cssNames.map(extractCSS);
@@ -36,7 +37,7 @@ const plugins = clean([
3637

3738
const rules = [{
3839
test: /\.css$/,
39-
exclude: /css\/(nojs|view|config|terminal|user-menu|columns.*)\.css/,
40+
exclude: /css\/(nojs|view|config|terminal|user-menu|columns.*|themes.*)\.css/,
4041
use: extractMain.extract(['css-loader']),
4142
}, ...cssPlugins.map(extract), {
4243
test: /\.(png|gif|svg|woff|woff2|eot|ttf)$/,

.webpack/html.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

3-
const HtmlWebpackPlugin = require('html-webpack-plugin');
43
const {env} = require('node:process');
4+
const HtmlWebpackPlugin = require('html-webpack-plugin');
55

66
const isDev = env.NODE_ENV === 'development';
77

HELP.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Cloud Commander supports the following command-line parameters:
9393
| `--terminal-command` | set command to run in terminal (shell by default)
9494
| `--terminal-auto-restart` | restart command on exit
9595
| `--vim` | enable vim hot keys
96-
| `--columns` | set visible columns
96+
| `--themes` | set visible themes
9797
| `--export` | enable export of config through a server
9898
| `--export-token` | authorization token used by export server
9999
| `--import` | enable import of config
@@ -122,7 +122,7 @@ Cloud Commander supports the following command-line parameters:
122122
| `--no-terminal-command` | set default shell to run in terminal
123123
| `--no-terminal-auto-restart` | do not restart command on exit
124124
| `--no-vim` | disable vim hot keys
125-
| `--no-columns` | set default visible columns
125+
| `--no-themes` | set default visible themes
126126
| `--no-export` | disable export config through a server
127127
| `--no-import` | disable import of config
128128
| `--no-import-listen` | disable listen on config updates from import server
@@ -408,7 +408,7 @@ Here's a description of all options:
408408
"terminalCommand": "", // set command to run in terminal
409409
"terminalAutoRestart": true, // restart command on exit
410410
"vim": false, // disable vim hot keys
411-
"columns": "name-size-date-owner-mode", // set visible columns
411+
"themes": "name-size-date-owner-mode", // set visible themes
412412
"export": false, // enable export of config through a server
413413
"exportToken": "root", // token used by export server
414414
"import": false, // enable import of config
@@ -428,7 +428,7 @@ Some config options can be overridden with environment variables, such as:
428428
- `CLOUDCMD_NAME` - set tab name in web browser
429429
- `CLOUDCMD_OPEN` - open web browser when server started
430430
- `CLOUDCMD_EDITOR` - set editor
431-
- `CLOUDCMD_COLUMNS` - set visible columns
431+
- `CLOUDCMD_COLUMNS` - set visible themes
432432
- `CLOUDCMD_CONTACT` - enable contact
433433
- `CLOUDCMD_CONFIG_DIALOG` - enable config dialog
434434
- `CLOUDCMD_CONFIG_AUTH` - enable auth change in config dialog

bin/cloudcmd.mjs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
#!/usr/bin/env node
22

3+
import process from 'node:process';
34
import {createRequire} from 'node:module';
45
import {promisify} from 'node:util';
56
import tryToCatch from 'try-to-catch';
67
import {createSimport} from 'simport';
78
import parse from 'yargs-parser';
8-
import process from 'node:process';
99
import exit from '../server/exit.js';
1010
import {createConfig, configPath} from '../server/config.js';
1111
import env from '../server/env.js';
1212
import prefixer from '../server/prefixer.js';
13+
import * as validate from '../server/validate.mjs';
1314

1415
process.on('unhandledRejection', exit);
1516

@@ -61,6 +62,7 @@ const yargsOptions = {
6162
'terminal-path',
6263
'terminal-command',
6364
'columns',
65+
'theme',
6466
'import-url',
6567
'import-token',
6668
'export-token',
@@ -112,6 +114,7 @@ const yargsOptions = {
112114
'contact': choose(env.bool('contact'), config('contact')),
113115
'terminal': choose(env.bool('terminal'), config('terminal')),
114116
'columns': env('columns') || config('columns') || '',
117+
'theme': env('theme') || config('theme') || '',
115118
'vim': choose(env.bool('vim'), config('vim')),
116119
'log': config('log'),
117120

@@ -174,6 +177,9 @@ async function main() {
174177
if (args.repl)
175178
repl();
176179

180+
validate.columns(args.columns);
181+
validate.theme(args.theme);
182+
177183
port(args.port);
178184

179185
config('name', args.name);
@@ -194,6 +200,7 @@ async function main() {
194200
config('prefixSocket', prefixer(args.prefixSocket));
195201
config('root', args.root || '/');
196202
config('vim', args.vim);
203+
config('theme', args.theme);
197204
config('columns', args.columns);
198205
config('log', args.log);
199206
config('confirmCopy', args.confirmCopy);
@@ -221,14 +228,15 @@ async function main() {
221228
prefix: config('prefix'),
222229
prefixSocket: config('prefixSocket'),
223230
columns: config('columns'),
231+
theme: config('theme'),
224232
};
225233

226234
const password = env('password') || args.password;
227235

228236
if (password)
229237
config('password', await getPassword(password));
230238

231-
await validateRoot(options.root, config);
239+
validateRoot(options.root, config);
232240

233241
if (args.showConfig)
234242
await showConfig();
@@ -245,8 +253,7 @@ async function main() {
245253
await importConfig(config);
246254
}
247255

248-
async function validateRoot(root, config) {
249-
const validate = await simport(`${DIR_SERVER}validate.js`);
256+
function validateRoot(root, config) {
250257
validate.root(root, config);
251258

252259
if (root === '/')

client/cloudcmd.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
'use strict';
22

33
const process = require('node:process');
4-
require('../css/main.css');
5-
require('../css/nojs.css');
6-
require('../css/columns/name-size-date.css');
7-
require('../css/columns/name-size.css');
4+
require('./css');
85

96
const wraptile = require('wraptile');
107
const load = require('load.js');

client/css.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict';
2+
3+
require('../css/main.css');
4+
require('../css/nojs.css');
5+
require('../css/columns/name-size-date.css');
6+
require('../css/columns/name-size.css');
7+
require('../css/themes/light.css');
8+
require('../css/themes/dark.css');

client/modules/config/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,15 @@ async function fillTemplate() {
137137
editor,
138138
packer,
139139
columns,
140+
theme,
140141
configAuth,
141142
...obj
142143
} = input.convert(config);
143144

144145
obj[`${editor}-selected`] = 'selected';
145146
obj[`${packer}-selected`] = 'selected';
146147
obj[`${columns}-selected`] = 'selected';
148+
obj[`${theme}-selected`] = 'selected';
147149
obj.configAuth = configAuth ? '' : 'hidden';
148150

149151
const innerHTML = rendy(Template, obj);

css/main.css

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* @import url(./themes/dark.css); */
2-
@import url(./themes/light.css);
31
@import url(./urls.css);
42
@import url(./reset.css);
53
@import url(./style.css);

css/style.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ code {
4141
-ms-user-select: initial;
4242
-o-user-select: initial;
4343
user-select: text;
44+
color: var(--column-color);
4445
}
4546

4647
.panel,

css/vars.css

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)