Skip to content

Commit 8d5129c

Browse files
committed
feat: fp-1499, core-styles pattern demo
1 parent da7c905 commit 8d5129c

File tree

17 files changed

+13075
-2133
lines changed

17 files changed

+13075
-2133
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ node_modules
55
.postcssrc.yml
66
dist
77

8+
# Fractal
9+
demo
10+
811
# IDE
912
.vscode
1013

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33
# do not format stylesheets until `nx format` ignores multiple blank lines
44
# https://prettier.io/docs/en/rationale.html#empty-lines
55
*.css
6+
7+
# do not format handlebars until there is a succinct solution for
8+
# "A block may only be used inside an HTML element or another block."
9+
*.hbs

README.md

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,6 @@ buildStylesheets(
119119
120120
## Local Development Setup
121121
122-
### Prequisites for Building the Styles
123-
124-
- Nodejs 16.x
125-
126-
> **Future**: The Core Styles will be rendered via a pattern library software.
127-
128122
### Code Configuration
129123
130124
Code configuration happens in repos that use these styles.
@@ -137,17 +131,20 @@ Code configuration happens in repos that use these styles.
137131
npm ci
138132
```
139133
140-
> **Future**:
141-
>
142-
> 2. Build stylesheets + Run the pattern library:
143-
>
144-
> ```bash
145-
> npm start
146-
> ```
147-
>
148-
> 3. Open the web interface.
149-
>
150-
> The build command will output the URL (and may even open it for you).
134+
2. Build stylesheets:
135+
136+
```bash
137+
npm run build:css
138+
```
139+
140+
3. Run the pattern library:
141+
142+
```bash
143+
npm start
144+
```
145+
146+
4. Open the web interface.
147+
The build command will output the URL (and may even open it for you).
151148
152149
[npm-install]: https://docs.npmjs.com/cli/v8/commands/npm-ci
153150
@@ -158,11 +155,9 @@ If you changes files in a `src/lib/` directory, you may need to follow some of t
158155
#### Quick Start
159156
160157
1. _(optional)_ Make changes to `/src/lib` files.
161-
2. Build the styles: `npm run build`
162-
163-
> **Future**: 2. Build and preview the styles: `npm start`
164-
165-
3. _(to debug)_ Review respective `/dist` files' content.
158+
2. Build the styles: `npm run build:css`
159+
3. Build and preview the styles: `npm start`
160+
4. _(to debug)_ Review respective `/dist` or `/demo` files' content.
166161
167162
#### How to Just Build Stylesheets
168163
@@ -171,20 +166,20 @@ You can build stylesheets **from** source files **in** `src/lib` directory **to*
171166
1. Build stylesheets:
172167
173168
```bash
174-
npm run build
169+
npm run build:css
175170
```
176171
177172
**or**, for custom build id:
178173
179174
```bash
180-
npm run build -- --build-id="..."
175+
npm run build:css -- --build-id="..."
181176
```
182177
183178
## Testing
184179
185-
Plugin testing is done manually. Run `npm run build` from root folder in this project, then review output in `/dist/_tests.css`, to ensure plugins are working correctly.
180+
Plugin testing is done manually. Run `npm run test`, then review output in `/dist/_tests.css`, to ensure plugins are working correctly.
186181
187-
> **Future**: Style testing is done manually. Run `npm start` from root folder in this project, then review output at web interface, to ensure styles are rendering correctly.
182+
Style testing is done manually. Run `npm start`, then review output at web interface, to ensure styles are rendering correctly.
188183
189184
### Production Deployment
190185

bin/build-css.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env node
2+
3+
/** Build CSS using the Core-Styles API */
4+
5+
const { buildStylesheets } = require('../src/main');
6+
7+
buildStylesheets('src/lib/_imports/**/*!(README).css', './dist', {
8+
baseMirrorDir: 'src/lib/_imports',
9+
});

bin/test-css.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env node
2+
3+
/** Test CSS plugins via the Core-Styles API */
4+
5+
const { buildStylesheets } = require('../src/main');
6+
7+
buildStylesheets('src/lib/_tests', './dist', {
8+
baseMirrorDir: 'src/lib',
9+
});

docs/_fractal.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# TACC Core Styles - Tips for Fractal Component Library
2+
3+
## Debugging
4+
5+
### Preview Templates
6+
7+
To see values available in a preview template, adapt this template code:
8+
9+
```html
10+
<dl>
11+
{{#each _target}}
12+
<dt>
13+
<strong><code>{{@key}}</code></strong>
14+
</dt>
15+
<dd><code>{{this}}</code></dd>
16+
{{/each}}
17+
</dl>
18+
```
19+
20+
### Console Logging
21+
22+
To output values (like objects) in the console, adapt this config code:
23+
24+
```js
25+
const hbs = require('@frctl/handlebars')({
26+
helpers: {
27+
debug: function (optionalValue) {
28+
console.log('Current Context');
29+
console.log('====================');
30+
console.log(this);
31+
32+
if (optionalValue) {
33+
console.log('Value');
34+
console.log('====================');
35+
console.log(optionalValue);
36+
}
37+
},
38+
},
39+
});
40+
fractal.components.engine(hbs);
41+
```

docs/index.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: TACC UI Patterns
3+
---
4+
5+
This is the UI pattern library for TACC.
6+
7+
The CSS for these patterns is available from [@tacc/core-styles].
8+
9+
---
10+
11+
Known Clients:
12+
13+
- [TACC/Core-CMS]
14+
- [TACC/Core-Portal]
15+
- [@tacc/core-components]
16+
17+
[tacc/core-cms]: https://github.com/TACC/Core-CMS
18+
[tacc/core-portal]: https://github.com/TACC/Core-Portal
19+
[@tacc/core-components]: https://www.npmjs.com/package/@tacc/core-components
20+
[@tacc/core-styles]: https://www.npmjs.com/package/@tacc/core-styles
21+
22+
<script type="module">
23+
Array.from(document.body.querySelectorAll('a'))
24+
.filter(link => link.hostname != window.location.hostname)
25+
.forEach(link => link.target = '_blank');
26+
</script>

fractal.config.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
'use strict';
2+
3+
const mandelbrot = require('@frctl/mandelbrot');
4+
const fractal = require('@frctl/fractal').create();
5+
6+
// Get base theme
7+
const themeConfig = require('./fractal.theme.js');
8+
const theme = mandelbrot(themeConfig);
9+
10+
// Configure UI
11+
fractal.set('project.title', 'TACC UI Patterns');
12+
fractal.components.set('label', 'Patterns'); // default is 'Components'
13+
fractal.components.set('title', 'Patterns'); // default is 'Components'
14+
fractal.components.set('default.status', 'wip'); // default is 'ready'
15+
16+
// Set source paths
17+
// (for components)
18+
fractal.components.set('path', __dirname + '/src/lib/_imports');
19+
fractal.components.set('resources', {
20+
// Render assets from component folders in a panel
21+
// WARNING: Undocumented feature
22+
// https://github.com/frctl/fractal/issues/150#issuecomment-254642411
23+
// https://github.com/frctl/fractal/issues/93#issuecomment-236429871
24+
assets: {
25+
label: 'Assets',
26+
match: ['**/*.css', '**/*.js'],
27+
},
28+
});
29+
// (for stylesheets)
30+
fractal.components.set('default.context', {
31+
styles: {
32+
internal: {
33+
local: [
34+
'/settings/border.css',
35+
'/settings/color.css',
36+
'/settings/font.css',
37+
'/settings/max-width.css',
38+
'/settings/space.css',
39+
],
40+
},
41+
},
42+
});
43+
44+
// Set website paths
45+
fractal.docs.set('path', __dirname + '/docs');
46+
fractal.web.set('static.path', __dirname + '/dist');
47+
fractal.web.set('builder.dest', __dirname + '/demo');
48+
49+
// Customize theme
50+
fractal.web.theme(theme);
51+
52+
// Export
53+
module.exports = fractal;

fractal.theme.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
3+
// To let any client extend
4+
module.exports = {
5+
skin: {
6+
accent: '#000000',
7+
complement: '#ffffff',
8+
links: '#784fe8',
9+
},
10+
panels: ['notes', 'html', 'resources', 'context', 'info'],
11+
nav: ['search', 'docs', 'components'],
12+
};

0 commit comments

Comments
 (0)