Skip to content

Commit ef71e2a

Browse files
committed
Adding minification options
1 parent 3651e41 commit ef71e2a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+416
-326
lines changed

.npmignore

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
docs
2-
!docs/dist/css/material-light.css
3-
!docs/dist/js/material.js
42
src
53
node_modules
64
.*

README.md

+33-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,42 @@
1-
#Content
1+
# Content
22

33
- About Material
44
- Getting started
5+
- Minify files
56
- Contributing
67

7-
#About Material
8-
Material is a CSS framework based on the Material Design guidelines.
8+
# About Material
9+
[Material](https://superdj.github.io/material/) is a CSS framework based on the Material Design guidelines.
910

10-
#Getting started
11+
# Getting started
1112
To get started all you need to do is run:
1213

13-
npm install smaterial
14+
npm i -D smaterial
1415

15-
This will install the required packages
16+
This will install the required packages.
17+
18+
Then you can either use the minified or source files. In order to use the minified files the easiest way is to import them into the desired stylesheet or js file.
19+
The minified files can be found in `~smaterial/docs/dist/css/material-light.css` and `~smaterial/docs/dist/js/material.js`
20+
21+
In order to use the source files for sass you can use:
22+
23+
@import '~smaterial/src/sass/material'
24+
25+
and for js:
26+
27+
import '~smaterial/src/js/main.js'
28+
29+
# Minify files
30+
To minify the output of both SASS and JS files there are a couple of tricks you can use. Do note that you need to use the source files.
31+
32+
## JS
33+
When using the source files for JS you can simply import only the required classes.
34+
How you can do this is shown below, the full list of classes can be found in `src/js/main.js`
35+
36+
## SASS
37+
For the SASS files there are a couple of ways to minify the output.
38+
The most simple way is to comment some of the imported partials from `src/sass/material.css`.
39+
However it's more efficient to adjust the defined arrays.
40+
41+
For example copy and paste the following variable into your own sass file: `$icon-settings: (18, 24, 36, 48);`.
42+
If you then delete `18` the class `.icon--18` will not be included in the outputted CSS file.

docs/dist/css/material-light.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/dist/css/material-light.css.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/dist/js/material-light.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/dist/js/material-light.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/dist/js/material.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/dist/js/material.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222
"css",
2323
"scss",
2424
"css",
25+
"front-end",
2526
"Google"
2627
],
2728
"author": "Derkjan Super",
2829
"files": [
29-
"docs/dist/{css,js}/*.{css,js,map}"
30+
"docs/dist/",
31+
"src/"
3032
],
3133
"devDependencies": {
3234
"@babel/core": "^7.4.3",

src/js/app-bar.js

-42
This file was deleted.

src/js/classes/AppBar.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export default class AppBar
2+
{
3+
constructor( appBar )
4+
{
5+
this.appBar = appBar;
6+
this.container = document.getElementsByClassName('.container')[0];
7+
8+
this.setHeight();
9+
}
10+
11+
setHeight()
12+
{
13+
[ 'resize', 'load', ].forEach( ( e ) =>
14+
{
15+
window.addEventListener( e, () =>
16+
{
17+
this.container.style.setProperty( '--app-bar-height', `${this.appBar.getBoundingClientRect().height}` );
18+
});
19+
});
20+
}
21+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/js/classes/Menu.js

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
export default class Menu
2+
{
3+
constructor( menu )
4+
{
5+
this.menu = menu;
6+
7+
this.addMutationObserver();
8+
}
9+
10+
addMutationObserver()
11+
{
12+
let observer = new MutationObserver( mutations =>
13+
{
14+
mutations.forEach( ( mutation ) =>
15+
{
16+
if( mutation.attributeName === 'class' )
17+
{
18+
let attributeValue = document.getElementById( mutation.target.id ).getAttribute( mutation.attributeName );
19+
20+
if( attributeValue.indexOf('active') > -1 )
21+
{
22+
this.menu.style.maxWidth = `100vw`;
23+
this.menu.style.maxHeight = `100vh`;
24+
}
25+
else
26+
{
27+
this.menu.style.maxWidth = 0;
28+
this.menu.style.maxHeight = 0;
29+
}
30+
}
31+
});
32+
});
33+
34+
observer.observe( this.menu, {
35+
attributes: true,
36+
});
37+
}
38+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/js/functions.js

-4
This file was deleted.

src/js/main.js

+31-16
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
1-
import Autocomplete from'js/classes/autocomplete';
2-
import Badge from'js/classes/badge';
3-
import Banner from'js/classes/banner';
4-
import Button from'js/classes/button';
5-
import DataTable from'js/classes/data-table';
6-
import Dialog from'js/classes/dialog';
7-
import Divider from'js/classes/divider';
8-
import Drawer from'js/classes/drawer';
9-
10-
import Progress from'js/classes/progress';
11-
import SelectField from'js/classes/select-field';
12-
import{ Switch, Checkbox, Radio } from'js/classes/selection';
13-
import Slider from'js/classes/slider';
14-
import TabBar from'js/classes/tab';
15-
import TextField from'js/classes/text-field';
16-
import Tooltip from'js/classes/tooltip';
1+
import AppBar from'js/classes/AppBar';
2+
import Autocomplete from'js/classes/Autocomplete';
3+
import Badge from'js/classes/Badge';
4+
import Banner from'js/classes/Banner';
5+
import Button from'js/classes/Button';
6+
import DataTable from'js/classes/DataTable';
7+
import Dialog from'js/classes/Dialog';
8+
import Divider from'js/classes/Divider';
9+
import Drawer from'js/classes/Drawer';
10+
import Menu from'js/classes/Menu';
11+
import Progress from'js/classes/Progress';
12+
import SelectField from'js/classes/SelectField';
13+
import{ Switch, Checkbox, Radio } from'js/classes/Selection';
14+
import Slider from'js/classes/Slider';
15+
import TabBar from'js/classes/Tab';
16+
import TextField from'js/classes/TextField';
17+
import Tooltip from'js/classes/Tooltip';
18+
19+
const appBars = document.getElementsByClassName('app-bar');
20+
21+
for( let appBar of appBars )
22+
{
23+
new AppBar( appBar );
24+
}
1725

1826
const autocompletes = document.getElementsByClassName('text-field--autocomplete');
1927

@@ -71,6 +79,13 @@ for( let drawer of drawers )
7179
new Drawer( drawer );
7280
}
7381

82+
const menus = document.getElementsByClassName( 'menu' );
83+
84+
for( let menu of menus )
85+
{
86+
new Menu( menu );
87+
}
88+
7489
const progressBars = document.getElementsByClassName( 'progress' );
7590

7691
for( let progressBar of progressBars )

src/js/menu.js

-48
This file was deleted.

0 commit comments

Comments
 (0)