import publik theming tools

This commit is contained in:
Thomas Jund 2020-09-28 17:24:08 +02:00
parent 6db737229e
commit d8bfd39c89
19 changed files with 678 additions and 0 deletions

57
new_theme.sh Executable file
View File

@ -0,0 +1,57 @@
#!/bin/bash
# folder Name
read -p 'folder name : ' folderName
# Theme Label
read -p 'Theme label : ' themeLabel
# Theme Color
read -p 'Theme Color (hexa) : ' themeColor
# Active PWA
read -p 'Active PWA (0/1) : ' pwa
cd ~/src/publik-base-theme/
# create folder
themefolderPath=static/$folderName
mkdir $themefolderPath
# store config PWA
if [ $pwa == 1 ]
then
configPWA='"pwa_display": "standalone",'
fi
# create config.json file
cat >${themefolderPath}/config.json <<EOF
{
"label": "${themeLabel}",
"variables": {
${configPWA}
"theme_color": "${themeColor}",
"email_header_asset": "emails:logo"
},
"settings": {
"combo": {
"COMBO_ASSET_SLOTS.update": {
"header:logo": { "label": "Têtière : logo" },
"emails:logo": {"label": "Emails : logo"}
}
}
}
}
EOF
# create css files
touch ${themefolderPath}/_vars.scss ${themefolderPath}/_custom.scss
cat >${themefolderPath}/style.scss <<EOF
@charset "UTF-8";
@import '../includes/fonts/source-sans-pro';
@import 'vars';
@import '../includes/publik';
@import 'custom';
EOF
# make
make themes.json
make css static/$folderName/style.css

18
npm_serve.js Normal file
View File

@ -0,0 +1,18 @@
const pkgJson = require('./package.json');
// const exec = require('child_process').exec;
const browserSync = require("browser-sync").create();
const apps = [ 'combo', 'wcs', 'authentic'];
const param = process.argv.pop();
const themeFolder = process.env.npm_package_config_themefolder;
const app = apps.includes(param) ? param : process.env.npm_package_config_app;
const appurl = pkgJson.config.url[app];
browserSync.init({
proxy: appurl,
files: [
`${themeFolder}/static/**/*.css`,
`${themeFolder}/templates/**/*`
],
logLevel: "debug"
})

34
package.json Normal file
View File

@ -0,0 +1,34 @@
{
"name": "Publik-watch-reload",
"version": "1.0.0",
"description": "Watch html & css files; run make css & themes; reload browser",
"author": "Thomas JUND",
"config": {
"url": {
"combo": "https://combo.dev.publik.love/",
"authentic": "https://authentic.dev.publik.love/accounts/register/",
"wcs": "https://wcs.dev.publik.love/form-test",
"agent-combo": "https://agent-combo.dev.publik.love/"
},
"themefolder": "publik-base-theme",
"theme": "thomas",
"app": "combo"
},
"scripts": {
"explore:css": "cd $npm_package_config_themefolder && postcss static/**/style.css --config postcss.config.js --dir /tmp/ > /tmp/explorecss.txt",
"stop:memcache": "sudo systemctl stop memcached",
"build:css": "cd $npm_package_config_themefolder && make static/$npm_package_config_theme/style.css",
"build:themes": "cd $npm_package_config_themefolder && make themes.json",
"watch:scss": "cd $npm_package_config_themefolder && chokidar 'static/**/*.scss' -c 'npm run build:css'",
"watch:config": "cd $npm_package_config_themefolder && chokidar 'static/**/config.json' -c 'npm run build:themes'",
"serve": "node npm_serve.js",
"dev": "run-p watch:* & npm run serve"
},
"devDependencies": {
"browser-sync": "^2.26.7",
"chokidar-cli": "^2.0.0",
"eslint": "^7.7.0",
"npm-run-all": "^4.1.5",
"postcss-cli": "^7.1.2"
}
}

View File

@ -0,0 +1,15 @@
root = true
[*]
charset = utf-8
end_of_line = lf
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{json,md,yml}]
indent_size = 2
indent_style = space

11
postcss-explore/.gitignore vendored Normal file
View File

@ -0,0 +1,11 @@
.*
!.editorconfig
!.gitignore
!.rollup.js
!.tape.js
!.travis.yml
*.log*
*.result.css
/index.*
node_modules
package-lock.json

View File

@ -0,0 +1,16 @@
import babel from 'rollup-plugin-babel';
export default {
input: 'src/index.js',
output: [
{ file: 'index.js', format: 'cjs', sourcemap: true, strict: false },
{ file: 'index.mjs', format: 'esm', sourcemap: true, strict: false }
],
plugins: [
babel({
presets: [
['@babel/env', { modules: false, targets: { node: 8 } }]
]
})
]
};

5
postcss-explore/.tape.js Normal file
View File

@ -0,0 +1,5 @@
module.exports = {
'basic': {
message: 'supports basic usage'
}
};

View File

@ -0,0 +1,9 @@
# https://docs.travis-ci.com/user/travis-lint
language: node_js
node_js:
- 8
install:
- npm install --ignore-scripts

View File

@ -0,0 +1,5 @@
# Changes to PostCSS postcss-explore
### 1.0.0 (September 18, 2020)
- Initial version

View File

@ -0,0 +1,65 @@
# Contributing to PostCSS postcss-explore
You want to help? You rock! Now, take a moment to be sure your contributions
make sense to everyone else.
## Reporting Issues
Found a problem? Want a new feature?
- See if your issue or idea has [already been reported].
- Provide a [reduced test case] or a [live example].
Remember, a bug is a _demonstrable problem_ caused by _our_ code.
## Submitting Pull Requests
Pull requests are the greatest contributions, so be sure they are focused in
scope and avoid unrelated commits.
1. To begin; [fork this project], clone your fork, and add our upstream.
```bash
# Clone your fork of the repo into the current directory
git clone git@github.com:YOUR_USER/postcss-postcss-explore.git
# Navigate to the newly cloned directory
cd postcss-postcss-explore
# Assign the original repo to a remote called "upstream"
git remote add upstream git@github.com:csstools/postcss-postcss-explore.git
# Install the tools necessary for testing
npm install
```
2. Create a branch for your feature or fix:
```bash
# Move into a new branch for your feature
git checkout -b feature/thing
```
```bash
# Move into a new branch for your fix
git checkout -b fix/something
```
3. If your code follows our practices, then push your feature branch:
```bash
# Test current code
npm test
```
```bash
# Push the branch for your new feature
git push origin feature/thing
```
```bash
# Or, push the branch for your update
git push origin update/something
```
Thats it! Now [open a pull request] with a clear title and description.
[already been reported]: issues
[fork this project]: fork
[live example]: https://codepen.io/pen
[open a pull request]: https://help.github.com/articles/using-pull-requests/
[reduced test case]: https://css-tricks.com/reduced-test-cases/

170
postcss-explore/INSTALL.md Normal file
View File

@ -0,0 +1,170 @@
# Installing PostCSS postcss-explore
[PostCSS postcss-explore] runs in all Node environments, with special instructions for:
| [Node](#node) | [PostCSS CLI](#postcss-cli) | [Webpack](#webpack) | [Create React App](#create-react-app) | [Gulp](#gulp) | [Grunt](#grunt) |
| --- | --- | --- | --- | --- | --- |
## Node
Add [PostCSS postcss-explore] to your project:
```bash
npm install postcss-postcss-explore --save-dev
```
Use **PostCSS postcss-explore** to process your CSS:
```js
const postcssPostcssExplore = require('postcss-postcss-explore');
postcssPostcssExplore.process(YOUR_CSS /*, processOptions, pluginOptions */);
```
Or use it as a [PostCSS] plugin:
```js
const postcss = require('postcss');
const postcssPostcssExplore = require('postcss-postcss-explore');
postcss([
postcssPostcssExplore(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);
```
## PostCSS CLI
Add [PostCSS CLI] to your project:
```bash
npm install postcss-cli --save-dev
```
Use **PostCSS postcss-explore** in your `postcss.config.js` configuration file:
```js
const postcssPostcssExplore = require('postcss-postcss-explore');
module.exports = {
plugins: [
postcssPostcssExplore(/* pluginOptions */)
]
}
```
## Webpack
Add [PostCSS Loader] to your project:
```bash
npm install postcss-loader --save-dev
```
Use **PostCSS postcss-explore** in your Webpack configuration:
```js
const postcssPostcssExplore = require('postcss-postcss-explore');
module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: [
'style-loader',
{ loader: 'css-loader', options: { importLoaders: 1 } },
{ loader: 'postcss-loader', options: {
ident: 'postcss',
plugins: () => [
postcssPostcssExplore(/* pluginOptions */)
]
} }
]
}
]
}
}
```
## Create React App
Add [React App Rewired] and [React App Rewire PostCSS] to your project:
```bash
npm install react-app-rewired react-app-rewire-postcss --save-dev
```
Use **React App Rewire PostCSS** and **PostCSS postcss-explore** in your
`config-overrides.js` file:
```js
const reactAppRewirePostcss = require('react-app-rewire-postcss');
const postcssPostcssExplore = require('postcss-postcss-explore');
module.exports = config => reactAppRewirePostcss(config, {
plugins: () => [
postcssPostcssExplore(/* pluginOptions */)
]
});
```
## Gulp
Add [Gulp PostCSS] to your project:
```bash
npm install gulp-postcss --save-dev
```
Use **PostCSS postcss-explore** in your Gulpfile:
```js
const postcss = require('gulp-postcss');
const postcssPostcssExplore = require('postcss-postcss-explore');
gulp.task('css', () => gulp.src('./src/*.css').pipe(
postcss([
postcssPostcssExplore(/* pluginOptions */)
])
).pipe(
gulp.dest('.')
));
```
## Grunt
Add [Grunt PostCSS] to your project:
```bash
npm install grunt-postcss --save-dev
```
Use **PostCSS postcss-explore** in your Gruntfile:
```js
const postcssPostcssExplore = require('postcss-postcss-explore');
grunt.loadNpmTasks('grunt-postcss');
grunt.initConfig({
postcss: {
options: {
use: [
postcssPostcssExplore(/* pluginOptions */)
]
},
dist: {
src: '*.css'
}
}
});
```
[Gulp PostCSS]: https://github.com/postcss/gulp-postcss
[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
[PostCSS]: https://github.com/postcss/postcss
[PostCSS CLI]: https://github.com/postcss/postcss-cli
[PostCSS Loader]: https://github.com/postcss/postcss-loader
[PostCSS postcss-explore]: https://github.com/sacripant/postcss-postcss-explore
[React App Rewire PostCSS]: https://github.com/csstools/react-app-rewire-postcss
[React App Rewired]: https://github.com/timarney/react-app-rewired

108
postcss-explore/LICENSE.md Normal file
View File

@ -0,0 +1,108 @@
# CC0 1.0 Universal
## Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator and
subsequent owner(s) (each and all, an “owner”) of an original work of
authorship and/or a database (each, a “Work”).
Certain owners wish to permanently relinquish those rights to a Work for the
purpose of contributing to a commons of creative, cultural and scientific works
(“Commons”) that the public can reliably and without fear of later claims of
infringement build upon, modify, incorporate in other works, reuse and
redistribute as freely as possible in any form whatsoever and for any purposes,
including without limitation commercial purposes. These owners may contribute
to the Commons to promote the ideal of a free culture and the further
production of creative, cultural and scientific works, or to gain reputation or
greater distribution for their Work in part through the use and efforts of
others.
For these and/or other purposes and motivations, and without any expectation of
additional consideration or compensation, the person associating CC0 with a
Work (the “Affirmer”), to the extent that he or she is an owner of Copyright
and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and
publicly distribute the Work under its terms, with knowledge of his or her
Copyright and Related Rights in the Work and the meaning and intended legal
effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights (“Copyright and
Related Rights”). Copyright and Related Rights include, but are not limited
to, the following:
1. the right to reproduce, adapt, distribute, perform, display, communicate,
and translate a Work;
2. moral rights retained by the original author(s) and/or performer(s);
3. publicity and privacy rights pertaining to a persons image or likeness
depicted in a Work;
4. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(i), below;
5. rights protecting the extraction, dissemination, use and reuse of data in
a Work;
6. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation thereof,
including any amended or successor version of such directive); and
7. other similar, equivalent or corresponding rights throughout the world
based on applicable law or treaty, and any national implementations
thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention of,
applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
unconditionally waives, abandons, and surrenders all of Affirmers Copyright
and Related Rights and associated claims and causes of action, whether now
known or unknown (including existing as well as future claims and causes of
action), in the Work (i) in all territories worldwide, (ii) for the maximum
duration provided by applicable law or treaty (including future time
extensions), (iii) in any current or future medium and for any number of
copies, and (iv) for any purpose whatsoever, including without limitation
commercial, advertising or promotional purposes (the “Waiver”). Affirmer
makes the Waiver for the benefit of each member of the public at large and
to the detriment of Affirmers heirs and successors, fully intending that
such Waiver shall not be subject to revocation, rescission, cancellation,
termination, or any other legal or equitable action to disrupt the quiet
enjoyment of the Work by the public as contemplated by Affirmers express
Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason be
judged legally invalid or ineffective under applicable law, then the Waiver
shall be preserved to the maximum extent permitted taking into account
Affirmers express Statement of Purpose. In addition, to the extent the
Waiver is so judged Affirmer hereby grants to each affected person a
royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmers Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future time
extensions), (iii) in any current or future medium and for any number of
copies, and (iv) for any purpose whatsoever, including without limitation
commercial, advertising or promotional purposes (the “License”). The License
shall be deemed effective as of the date CC0 was applied by Affirmer to the
Work. Should any part of the License for any reason be judged legally
invalid or ineffective under applicable law, such partial invalidity or
ineffectiveness shall not invalidate the remainder of the License, and in
such case Affirmer hereby affirms that he or she will not (i) exercise any
of his or her remaining Copyright and Related Rights in the Work or (ii)
assert any associated claims and causes of action with respect to the Work,
in either case contrary to Affirmers express Statement of Purpose.
4. Limitations and Disclaimers.
1. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
2. Affirmer offers the Work as-is and makes no representations or warranties
of any kind concerning the Work, express, implied, statutory or
otherwise, including without limitation warranties of title,
merchantability, fitness for a particular purpose, non infringement, or
the absence of latent or other defects, accuracy, or the present or
absence of errors, whether or not discoverable, all to the greatest
extent permissible under applicable law.
3. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any persons Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the Work.
4. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to this
CC0 or use of the Work.
For more information, please see
http://creativecommons.org/publicdomain/zero/1.0/.

61
postcss-explore/README.md Normal file
View File

@ -0,0 +1,61 @@
# PostCSS postcss-explore [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS" width="90" height="90" align="right">][postcss]
[![NPM Version][npm-img]][npm-url]
[![Build Status][cli-img]][cli-url]
[![Support Chat][git-img]][git-url]
[PostCSS postcss-explore] lets you ... in CSS.
```pcss
.example { ... }
/* becomes */
.example { ... }
```
## Usage
Add [PostCSS postcss-explore] to your project:
```bash
npm install postcss-postcss-explore --save-dev
```
Use **PostCSS postcss-explore** to process your CSS:
```js
const postcssPostcssExplore = require('postcss-postcss-explore');
postcssPostcssExplore.process(YOUR_CSS /*, processOptions, pluginOptions */);
```
Or use it as a [PostCSS] plugin:
```js
const postcss = require('postcss');
const postcssPostcssExplore = require('postcss-postcss-explore');
postcss([
postcssPostcssExplore(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);
```
**PostCSS postcss-explore** runs in all Node environments, with special instructions for:
| [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Create React App](INSTALL.md#create-react-app) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) |
| --- | --- | --- | --- | --- | --- |
## Options
...
[cli-img]: https://img.shields.io/travis/sacripant/postcss-postcss-explore/master.svg
[cli-url]: https://travis-ci.org/sacripant/postcss-postcss-explore
[git-img]: https://img.shields.io/badge/support-chat-blue.svg
[git-url]: https://gitter.im/postcss/postcss
[npm-img]: https://img.shields.io/npm/v/postcss-postcss-explore.svg
[npm-url]: https://www.npmjs.com/package/postcss-postcss-explore
[PostCSS]: https://github.com/postcss/postcss
[PostCSS postcss-explore]: https://github.com/sacripant/postcss-postcss-explore

View File

@ -0,0 +1,63 @@
{
"name": "postcss-postcss-explore",
"version": "1.0.0",
"description": "... in CSS",
"author": "Jund <tjund@entrouvert.com>",
"license": "CC0-1.0",
"repository": "sacripant/postcss-postcss-explore",
"homepage": "https://github.com/sacripant/postcss-postcss-explore#readme",
"bugs": "https://github.com/sacripant/postcss-postcss-explore/issues",
"main": "index.js",
"module": "index.mjs",
"files": [
"index.js",
"index.js.map",
"index.mjs",
"index.mjs.map"
],
"scripts": {
"build": "rollup --config .rollup.js --silent",
"prepublishOnly": "npm test",
"pretest:tape": "npm run build",
"test": "npm run test:js && npm run test:tape",
"test:js": "eslint src/{*,**/*}.js --cache --ignore-path .gitignore --quiet",
"test:tape": "postcss-tape"
},
"engines": {
"node": ">=8.0.0"
},
"dependencies": {
"postcss": "^7.0.21"
},
"devDependencies": {
"@babel/core": "^7.7.2",
"@babel/preset-env": "^7.7.1",
"babel-eslint": "^10.0.3",
"eslint": "^6.6.0",
"postcss-tape": "^5.0.2",
"pre-commit": "^1.2.2",
"rollup": "^1.26.3",
"rollup-plugin-babel": "^4.3.3"
},
"eslintConfig": {
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 2018,
"impliedStrict": true,
"sourceType": "module"
},
"root": true
},
"keywords": [
"postcss",
"css",
"postcss-plugin",
""
]
}

View File

@ -0,0 +1,28 @@
import postcss from 'postcss';
export default postcss.plugin('postcss-postcss-explore', opts => {
return (root) => {
// console.log({ root, result }); // eslint-disable-line no-console
let startLine = 0;
root.walkComments( (comment) => {
if (comment.text == "End of core styles")
startLine = comment.source.start.line;
});
root.walkRules( opts.selector, (rule, index) => {
const ruleLine = rule.source.start.line;
if (ruleLine <= startLine) return;
rule.walkDecls( opts.propertie, decl => {
console.group(rule.source.input.from);
console.group(rule.selector);
console.log(decl.prop, decl.value);
console.log(decl.source.start);
console.groupEnd();
console.groupEnd();
console.log("");
});
});
};
});

View File

View File

8
postcss.config.js Normal file
View File

@ -0,0 +1,8 @@
module.exports = {
plugins: [
require('postcss-explore')({
selector: /\.cell$/,
propertie: /^border/
})
],
}

5
update_publik.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
cd ~/src/publik-devinst
git pull
ansible-playbook -K -i thomas-inventory.yml install.yml