-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…r-dark-logos GH-191: Theme (for ProTX Light Header & TACC Blue Header)
- Loading branch information
Showing
17 changed files
with
158 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env python | ||
|
||
# Allow a script to temporarily hide `print` output | ||
# SEE: https://gist.github.com/djsmith42/3956189#file-gistfile1-py | ||
# SEE: https://thesmithfam.org/blog/2012/10/25/temporarily-suppress-console-output-in-python/ | ||
|
||
from contextlib import contextmanager | ||
import sys, os | ||
|
||
@contextmanager | ||
def suppress_stdout(): | ||
with open(os.devnull, "w") as devnull: | ||
old_stdout = sys.stdout | ||
sys.stdout = devnull | ||
try: | ||
yield | ||
finally: | ||
sys.stdout = old_stdout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env python | ||
import os | ||
import sys | ||
import json | ||
|
||
from django.conf import settings | ||
|
||
from bin.suppress_stdout import suppress_stdout | ||
|
||
# Support isolated reading of settings | ||
sys.path.insert(0, os.getcwd()) | ||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "taccsite_cms.settings") | ||
|
||
# Create JSON | ||
setting_names = ["THEME"] | ||
settings_export = {} | ||
# FAQ: Any print() statements in settings.py would corrupt the JSON | ||
with suppress_stdout(): | ||
for setting_name in setting_names: | ||
settings_export[setting_name] = getattr(settings, setting_name) | ||
|
||
# Write JSON | ||
with open('taccsite_cms/settings.json', 'w', encoding='utf-8') as outfile: | ||
settings_json = json.dumps(settings_export, ensure_ascii=False, indent=2) | ||
outfile.write(settings_json + '\n') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,5 @@ Styleguide Scope.Footer | |
margin: 0; | ||
} | ||
.s-footer a { | ||
color: #cccccc; | ||
color: var(--global-color-primary--light); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# TACC CMS - Stylesheets - Themes | ||
|
||
AUTHOR THEME VALUES HERE! | ||
|
||
These values are only to be imported by PostCSS configuration. | ||
|
||
## Rules | ||
|
||
1. Theme data files __must__ be prefixed with `theme.`. | ||
2. Theme data files __must__ be `.json` format and extension. | ||
|
||
## Content Format | ||
|
||
See [PostCSS Preset Env's `importFrom` example content](https://github.com/csstools/postcss-preset-env#importfrom). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# TACC CMS - Stylesheets - Themes | ||
|
||
- Migrate `/taccsite_cms/site_shared/css/src/_imports/settings/*` to theme data. | ||
- Support one theme extending another theme (default theme or another theme). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Export appropriate theme file based on settings value | ||
*/ | ||
const rootPath = __dirname + '/../../../../../../'; | ||
const settings = require( rootPath + 'taccsite_cms/settings.json'); | ||
const theme = settings.THEME || 'default'; | ||
|
||
/** | ||
* Perform `require` but on fail: | ||
* - execute callback | ||
* - exit program (as fatal exception) | ||
* @param {string} modulePath - Path to the module to require | ||
* @param {function} callback - Callback (returns exception from `require()`) | ||
* @return {*} Content of the module (if successfully required) | ||
* @see https://stackoverflow.com/a/34005010/11817077 | ||
*/ | ||
function requireOrElse(modulePath, callback) { | ||
try { | ||
return require(modulePath); | ||
} | ||
catch (e) { | ||
if (typeof callback === 'function') { | ||
callback(e); | ||
} | ||
process.exit(1); | ||
} | ||
} | ||
|
||
const data = requireOrElse(`./theme.${theme}.json`, () => { | ||
console.error(`Unable to find '${__dirname}/theme.${theme}.json'`); | ||
}); | ||
|
||
module.exports = data; |
16 changes: 16 additions & 0 deletions
16
taccsite_cms/static/site_cms/css/src/_themes/theme.default.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"//": "Metadata for humans", | ||
"format": "https://github.com/csstools/postcss-preset-env#importfrom", | ||
"name": "default", | ||
|
||
"environment-variables": { | ||
|
||
"// HEADER": "", | ||
"--header-text-color": "var(--global-color-primary--xx-light)", | ||
"--header-bkgd-color": "var(--global-color-primary--xx-dark)", | ||
"--header-minor-border-color": "var(--global-color-primary--normal)", | ||
"// To 'hide' border by setting its color to match background color": "", | ||
"--header-major-border-color": "var(--global-color-primary--xx-dark)" | ||
|
||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
taccsite_cms/static/site_cms/css/src/_themes/theme.has-dark-logo.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"//": "Metadata for humans", | ||
"format": "https://github.com/csstools/postcss-preset-env#importfrom", | ||
"name": "has-dark-logo", | ||
|
||
"environment-variables": { | ||
|
||
"// HEADER": "", | ||
"--header-text-color": "var(--global-color-primary--x-dark)", | ||
"--header-bkgd-color": "var(--global-color-primary--x-light)", | ||
"--header-minor-border-color": "var(--global-color-primary--normal)", | ||
"// To show border between only the light header and content below it": "", | ||
"--header-major-border-color": "var(--global-color-primary--normal)" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters