diff --git a/README.md b/README.md index 0e94d58..aedc231 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ These themes have been tested and work: - Adwaita (GNOME & Fedora default) - Arc - Canta +- Cabinet - ChromeOS - Flat-Remix-GTK - HighContrast diff --git a/ego_description.txt b/ego_description.txt index e7fc9a1..849ca3e 100644 --- a/ego_description.txt +++ b/ego_description.txt @@ -4,6 +4,7 @@ These themes have been tested and work: - Adapta - Adwaita (GNOME & Fedora default) - Arc +- Cabinet - Canta - ChromeOS - Flat-Remix-GTK diff --git a/src/modules/Variants.js b/src/modules/Variants.js index 665af5b..a1cde44 100644 --- a/src/modules/Variants.js +++ b/src/modules/Variants.js @@ -52,9 +52,10 @@ var Variants = class { variants.set('day', name.replace('-Nokto', '')); variants.set('night', variants.get('day').replace('Adapta', 'Adapta-Nokto')); } - else if ( name.includes('Arc') ) { + else if ( name.match(/^(Arc|Cabinet)/) ) { + const basename = name.split('-')[0]; variants.set('day', name.replace(/-Dark(?!er)/, '')); - variants.set('night', variants.get('day').replace(/Arc(-Darker)?/, 'Arc-Dark')); + variants.set('night', variants.get('day').replace(new RegExp(`${basename}(-Darker)?`), `${basename}-Dark`)); } else if ( name.match(/^(Canta|ChromeOS|Materia|Orchis).*-compact/) ) { variants.set('day', name.replace('-dark', '')); diff --git a/tests/Cabinet.js b/tests/Cabinet.js new file mode 100644 index 0000000..337bfa3 --- /dev/null +++ b/tests/Cabinet.js @@ -0,0 +1,41 @@ +/* +Night Theme Switcher Gnome Shell extension + +Copyright (C) 2020 Romain Vigier + +This program is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see . +*/ + +const test = require('ava'); +const { Variants } = require('./_variants'); + + +['Blue', 'Green', 'Orange'].forEach(color => { + test(`Cabinet-${color}`, t => { + const variants = Variants.guess_from(`Cabinet-${color}`); + t.is(variants.get('day'), `Cabinet-${color}`); + t.is(variants.get('night'), `Cabinet-Dark-${color}`); + }); + + test(`Cabinet-Dark-${color}`, t => { + const variants = Variants.guess_from(`Cabinet-Dark-${color}`); + t.is(variants.get('day'), `Cabinet-${color}`); + t.is(variants.get('night'), `Cabinet-Dark-${color}`); + }); + + test(`Cabinet-Darker-${color}`, t => { + const variants = Variants.guess_from(`Cabinet-Darker-${color}`); + t.is(variants.get('day'), `Cabinet-Darker-${color}`); + t.is(variants.get('night'), `Cabinet-Dark-${color}`); + }); +});