Skip to content

Commit fa08cff

Browse files
authored
CSS Styling
- Refactored styling to be done via CSS variables rather than JavaScript during initialization - Added CSS variable knobs to the demo page
1 parent 82ff8f7 commit fa08cff

File tree

10 files changed

+450
-316
lines changed

10 files changed

+450
-316
lines changed

.github/workflows/npm_publish.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ on:
77
# Triggers the workflow on push or pull request events but only for the master branch
88
push:
99
branches: [ master ]
10-
pull_request:
11-
branches: [ master ]
1210

1311
# Allows you to run this workflow manually from the Actions tab
1412
workflow_dispatch:

README.md

Lines changed: 58 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ A web component for displaying the steps of a process and letting users move bet
1010

1111
### CDN
1212

13-
Use the built file from npm from https://unpkg.com/progress-steps-webcomponent@latest
13+
Use the built files from npm from https://unpkg.com/progress-steps-webcomponent@latest
1414

1515
```html
16-
<!-- For example -->
17-
<script src="https://unpkg.com/progress-steps-webcomponent@latest"></script>
16+
<!-- For example, use a CDN and replace 'latest' with your intended version -->
17+
<link rel="stylesheet" href="https://unpkg.com/progress-steps-webcomponent@latest/dist/progress-steps.min.css"/>
18+
<script src="https://unpkg.com/progress-steps-webcomponent@latest/dist/progress-steps.min.js"></script>
1819
```
1920

2021
### Manual
@@ -26,7 +27,7 @@ npm i
2627
npm run build
2728
```
2829

29-
And use the `dist/progress-steps.min.js` file
30+
And use the `dist/progress-steps.min.js` and `dist/progress-steps.min.css` files
3031

3132
## Configuration
3233

@@ -94,53 +95,56 @@ myStepper.init({
9495

9596
### Styling
9697

97-
Styling can be overridden by passing in CSS values to the `style` object. All options are entirely optional.
98-
The most commonly overridden value would be that of the color that the bar fills up with, `progressFillColor`
99-
100-
```js
101-
myStepper.init({
102-
steps: [
103-
...
104-
],
105-
style: {
106-
// The width of each step icon
107-
stepWidth: 20,
108-
// The font size of the step number and label
109-
fontSize: 12,
110-
// The border radius of the step icon
111-
borderRadius: '25%',
112-
// The thickness of the line/progress bar/borders
113-
lineThickness: 2,
114-
// The animation speed of the progress bar filling up
115-
animationSpeed: '500ms',
116-
// Whether or not to show labels or not
117-
showLabels: true,
118-
// The vertical margin of the labels, if shown
119-
labelSpacing: 5,
120-
// The font weight to use on step labels
121-
stepLabelFontWeight: 'normal',
122-
// The font color of step labels that are before the current step
123-
previousLabelFontColor: 'red',
124-
// The font color of the current step label
125-
currentLabelFontColor: 'blue',
126-
// The font weight of the current step label
127-
currentStepLabelFontWeight: 'bold',
128-
// The font color of step labels that are after the current step
129-
futureLabelFontColor: 'green',
130-
// The font color of step labels that are disabled
131-
disabledLabelFontColor: 'maroon',
132-
// The color to fill up, left-to-right, as steps are set to active
133-
progressFillColor: '#cf78d9',
134-
// The default color of the unfilled section of line and steps after the active step
135-
progressUnfilledColor: '#d5dce2',
136-
// The font color of the step icon that is currently active
137-
currentStepFontColor: 'white',
138-
// The fill-color for step icons that are after the current active step
139-
futureStepFillColor: 'orange',
140-
// The font color of the disabled steps
141-
disabledStepFontColor: 'red',
142-
// The fill-color for disabled step icons
143-
disabledStepFillColor: 'blue'
144-
},
145-
});
146-
```
98+
Styling defaults can be overridden by overriding CSS variables on your component instance:
99+
100+
```css
101+
/* Ugly but complete style override demonstrating all the style components */
102+
#my-steps{
103+
/* The color to fill up, left-to-right, as steps are set to active */
104+
--progress-fill-color: #cf78d9;
105+
/* The default color of the unfilled section of line and steps after the active step */
106+
--progress-unfilled-color: purple;
107+
108+
/* The width of each step icon */
109+
--step-width: 20px;
110+
/* The font size of the step number and label */
111+
--font-size: 12px;
112+
/* The border radius of the step icon */
113+
--step-border-radius: 25%;
114+
/* The thickness of the line/progress bar/borders */
115+
--line-thickness: 3px;
116+
117+
/* The animation speed of the progress bar filling up */
118+
--animation-speed: 500ms;
119+
/* Display attribute of the step labels. Show: 'inline-block', hide: 'none' */
120+
--step-label-display: 'inline-block';
121+
/* The vertical margin of the labels, if shown */
122+
--step-label-spacing: 5px;
123+
/* The font weight to use on step labels */
124+
--step-label-font-weight: normal;
125+
126+
/* The font color of the step icon that is currently active */
127+
--current-step-font-color: red;
128+
/* The font color of the current step label */
129+
--current-label-font-color: blue;
130+
/* The font weight of the current step label */
131+
--current-label-font-weight: bold;
132+
133+
/* The font color of step labels that are before the current step */
134+
--previous-label-font-color: red;
135+
/* The font color of the step icons that are before the current step */
136+
--previous-step-font-color: pink;
137+
138+
/* The fill-color for step icons that are after the current active step */
139+
--future-step-fill-color: orange;
140+
/* The font color of step labels that are after the current step */
141+
--future-label-font-color: green;
142+
143+
/* The font color of step labels that are disabled */
144+
--disabled-label-font-color: maroon;
145+
/* The font color of the disabled steps */
146+
--disabled-step-font-color: red;
147+
/* The fill-color for disabled step icons */
148+
--disabled-step-fill-color: blue;
149+
}
150+
```

build.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
// Requires
22
var fs = require('fs');
33
var UglifyJS = require('uglify-js');
4+
var UglifyCSS = require('uglifycss');
45

56
// Vars
67
var scriptFileName = 'progress-steps';
78
var dir = __dirname;
89
var sourceFolder = dir + '/src/';
910
var distFolder = dir + '/dist/';
1011

11-
// Minification
12+
// JS Minification
1213
var code = fs.readFileSync(sourceFolder + scriptFileName + '.js', 'utf8');
1314
var uglifiedCode = UglifyJS.minify(code, {
1415
mangle: {
@@ -17,6 +18,12 @@ var uglifiedCode = UglifyJS.minify(code, {
1718
nameCache: {},
1819
}).code;
1920

21+
// CSS Minification
22+
var css = fs.readFileSync(sourceFolder + scriptFileName + '.css', 'utf8');
23+
var uglifiedCss = UglifyCSS.processString(css, {
24+
});
25+
26+
2027
// Create dist folder if not exists
2128
if (!fs.existsSync(distFolder)) {
2229
fs.mkdirSync(distFolder);
@@ -34,3 +41,16 @@ fs.writeFile(
3441
}
3542
}
3643
);
44+
45+
// Create the CSS
46+
fs.writeFile(
47+
distFolder + scriptFileName + '.min.css',
48+
uglifiedCss,
49+
function (err) {
50+
if (err) {
51+
console.log(err);
52+
} else {
53+
console.log('Minified css saved');
54+
}
55+
}
56+
);

dist/progress-steps.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)