Skip to content

Commit 00aafe8

Browse files
authored
Merge branch 'master' into feature/polyfills
2 parents 916747f + 519a27e commit 00aafe8

File tree

12 files changed

+227
-22
lines changed

12 files changed

+227
-22
lines changed

package-lock.json

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

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"webpack": "^4.32.2",
6464
"webpack-cli": "^3.3.2",
6565
"webpack-manifest-plugin": "^2.0.4",
66-
"webpack-progress-ora-plugin": "^1.2.1"
66+
"webpack-progress-ora-plugin": "^1.2.1",
67+
"what-input": "^5.2.6"
6768
}
6869
}

src/js/app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Main scripts file
33
*/
44

5+
import 'what-input'
56
import './polyfill/picturefill'
67
import './polyfill/objectfit-polyfill'
78
import lazySizes from 'lazysizes'
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
// TODO: remove lodash and other dependencies
2+
var _ = require('lodash')
3+
var path = require('path')
4+
var url = require('url')
5+
var fs = require('fs')
6+
7+
function PhpOutputPlugin(options) {
8+
var defaults = {
9+
outPutPath: false, // false for default webpack path of pass string to specify
10+
assetsPathPrefix: '',
11+
phpClassName: 'WebpackBuiltFiles', //
12+
phpFileName: 'WebpackBuiltFiles',
13+
nameSpace: false, // false {nameSpace: 'name', use: ['string'] or empty property or don't pass "use" property}
14+
path: '',
15+
extraPurePatches: [],
16+
}
17+
18+
this.options = _.defaults(options, defaults)
19+
}
20+
21+
PhpOutputPlugin.prototype.apply = function apply(compiler) {
22+
var options = this.options
23+
24+
var getCssFiles = function(filelist, filepath) {
25+
return _.map(
26+
_.filter(filelist, filename => filename.endsWith('.css') && !filename.startsWith('editor-style')), // filtering
27+
filename => path.join(options.assetsPathPrefix, filepath, filename) // mapping filtered
28+
)
29+
}
30+
31+
var getJsFiles = function(filelist, filepath) {
32+
let files = _.map(
33+
_.filter(filelist, filename => filename.endsWith('.js') && !filename.startsWith('editor-style')), // filtering
34+
filename => path.join(options.assetsPathPrefix, filepath, filename) // mapping filtered
35+
)
36+
37+
if (options.extraPurePatches.length) {
38+
files = files.concat(options.extraPurePatches)
39+
}
40+
41+
// return files.sort().reverse()
42+
return files
43+
}
44+
45+
var arrayToPhpStatic = function(list, varname) {
46+
var out = ' static $' + varname + ' = [\n'
47+
_.forEach(list, function(item) {
48+
out += " '" + item + "',"
49+
})
50+
out += '\n ];\n'
51+
return out
52+
}
53+
54+
var objectToPhpClass = function(obj) {
55+
// Create a header string for the generated file:
56+
var out = '<?php\n\n'
57+
58+
if (options.nameSpace) {
59+
let nameSpaceVal = _.isString(options.nameSpace) ? options.nameSpace : options.nameSpace.nameSpace
60+
out += 'namespace ' + nameSpaceVal + '; \n\n'
61+
if (options.nameSpace.use && options.nameSpace.use.length) {
62+
_.forEach(options.nameSpace.use, use => {
63+
out += 'use ' + use + ';\n'
64+
})
65+
}
66+
}
67+
out += 'class ' + options.phpClassName + ' {\n'
68+
69+
_.forEach(obj, (list, name) => {
70+
out += arrayToPhpStatic(list, name)
71+
})
72+
73+
out += '\n}\n'
74+
return out
75+
}
76+
77+
var mkOutputDir = function(dir) {
78+
// Make webpack output directory if it doesn't already exist
79+
try {
80+
fs.mkdirSync(dir)
81+
} catch (err) {
82+
// If it does exist, don't worry unless there's another error
83+
if (err.code !== 'EEXIST') throw err
84+
}
85+
}
86+
87+
compiler.plugin('emit', function(compilation, callback) {
88+
var stats = compilation.getStats().toJson()
89+
var toInclude = []
90+
91+
// Flatten the chunks (lists of files) to one list
92+
for (var chunkName in stats.assetsByChunkName) {
93+
var asset = stats.assetsByChunkName[chunkName]
94+
95+
if (typeof asset === 'string') {
96+
toInclude.push(asset)
97+
} else if (Array.isArray(asset)) {
98+
toInclude = _.union(toInclude, asset)
99+
}
100+
}
101+
102+
var out = objectToPhpClass({
103+
jsFiles: getJsFiles(toInclude, options.path),
104+
cssFiles: getCssFiles(toInclude, options.path),
105+
})
106+
107+
// Write file using fs
108+
// Build directory if it doesn't exist
109+
var outPutPath = options.outPutPath ? options.outPutPath : compiler.options.output.path
110+
111+
mkOutputDir(path.resolve(outPutPath))
112+
fs.writeFileSync(path.join(outPutPath, options.phpFileName + '.php'), out)
113+
114+
callback()
115+
})
116+
}
117+
118+
module.exports = PhpOutputPlugin

src/scss/base/_focus.scss

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
html {
2+
a,
3+
button,
4+
input,
5+
select,
6+
textarea {
7+
&:focus {
8+
outline: 2px solid currentColor;
9+
outline-offset: .5rem;
10+
}
11+
}
12+
[data-seo-container] {
13+
&:focus-within {
14+
outline-offset: .5rem;
15+
outline: 1px solid currentColor;
16+
}
17+
*:focus {
18+
outline: none;
19+
}
20+
}
21+
&:not([data-whatintent="keyboard"]) {
22+
a,
23+
button,
24+
input,
25+
select,
26+
textarea {
27+
&:focus {
28+
outline: none;
29+
}
30+
}
31+
[data-seo-container] {
32+
&:focus-within,
33+
*:focus {
34+
outline: none;
35+
}
36+
}
37+
}
38+
}

src/scss/base/_seo.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[data-seo-container] {
22
position: relative;
33

4-
@include hover {
4+
&:hover {
55
cursor: pointer;
66
}
77

src/scss/patterns/_menu.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
@include clearfix;
4545

4646
&>#{$menu-item} {
47-
@include hover {
47+
&:hover,
48+
&:focus-within {
4849
ul {
4950
display: block;
5051
}

src/scss/style.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
@import "base/seo";
2626
@import "base/lazyload";
2727
@import "base/layout";
28+
@import "base/focus";
2829

2930
//Wordpress
3031
@import "wp/wpforms";

src/templates/partials/footer.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
<p>Follow us:</p>
55
<a class="button button--circle" href="https://www.facebook.com/beapi.agency/?ref=bookmarks">
66
<span class="visuallyhidden">On Facebook</span>
7-
<svg class="icon icon-facebook" aria-hidden="true" role="img">
7+
<svg class="icon icon-facebook" focusable="false" aria-hidden="true" role="img">
88
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-facebook"></use>
99
</svg>
1010
</a>
1111
<a class="button button--circle" href="https://twitter.com/be_api">
1212
<span class="visuallyhidden">On Twitter</span>
13-
<svg class="icon icon-twitter" aria-hidden="true" role="img">
13+
<svg class="icon icon-twitter" focusable="false" aria-hidden="true" role="img">
1414
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-twitter"></use>
1515
</svg>
1616
</a>
1717
<a class="button button--circle" href="https://www.instagram.com/agencebeapi/">
1818
<span class="visuallyhidden">On Instagram</span>
19-
<svg class="icon icon-instagram" aria-hidden="true" role="img">
19+
<svg class="icon icon-instagram" focusable="false" aria-hidden="true" role="img">
2020
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-instagram"></use>
2121
</svg>
2222
</a>
@@ -45,6 +45,13 @@ function loadJS(e,t){"use strict";var n=window.document.getElementsByTagName("sc
4545
</script>
4646

4747
<!-- Theme js -->
48-
<script src="assets/app.js" async defer></script>
48+
<?php
49+
if ( is_readable( dirname( __FILE__ ) . '/../WebpackBuiltFiles.php' ) ) {
50+
require_once dirname( __FILE__ ) . '/../WebpackBuiltFiles.php';
51+
foreach ( WebpackBuiltFiles::$jsFiles as $file ) { ?>
52+
<script src="assets/<?php echo $file; ?>" async defer></script>
53+
<?php }
54+
}
55+
?>
4956
</body>
5057
</html>

src/templates/partials/header.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,14 @@
4545
<script type="text/javascript" src="assets/js/vendor_ie/placeholders.min.js"></script>
4646
<![endif]-->
4747

48-
<link rel="stylesheet" href="assets/app.css">
48+
<?php
49+
if ( is_readable( dirname( __FILE__ ) . '/../WebpackBuiltFiles.php' ) ) {
50+
require_once dirname( __FILE__ ) . '/../WebpackBuiltFiles.php';
51+
foreach ( WebpackBuiltFiles::$cssFiles as $file ) { ?>
52+
<link rel="stylesheet" href="assets/<?php echo $file; ?>">
53+
<?php }
54+
}
55+
?>
4956

5057
<!-- jQuery from official WordPress Core -->
5158
<script type="text/javascript" src="assets/js/vendor_async/jquery.js"></script>
@@ -61,13 +68,13 @@
6168
</ul>
6269
<div id="js-menu-trigger" class="menu-trigger">
6370
<button type="button" id="js-menu-open" class="menu-trigger__open button button--primary">
64-
<svg class="icon icon-menu" aria-hidden="true" role="img">
71+
<svg class="icon icon-menu" focusable="false" aria-hidden="true" role="img">
6572
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-menu"></use>
6673
</svg>
6774
Menu
6875
</button>
6976
<button type="button" id="js-menu-close" class="menu-trigger__close button button--primary">
70-
<svg class="icon icon-close" aria-hidden="true" role="img">
77+
<svg class="icon icon-close" focusable="false" aria-hidden="true" role="img">
7178
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-close"></use>
7279
</svg>
7380
Fermer
@@ -78,7 +85,7 @@
7885
<div class="header__logo">
7986
<a href="01-home.php" class="header__logo-link">
8087
<!-- <?php //echo get_the_post_thumbnail( 0, 'logo-beapi', array( 'data-location' => 'header-logo', 'class' => 'header__img', 'alt' => 'Logo' ) ); ?> -->
81-
<svg class="header__icon icon" aria-hidden="true" role="img">
88+
<svg class="header__icon icon" focusable="false" aria-hidden="true" role="img">
8289
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-logo-beapi"></use>
8390
</svg>
8491
<?php if ( $bodyClass == 'home' ) :?>
@@ -93,7 +100,8 @@
93100
<li class="menu-item current-menu-item menu-item-has-children">
94101
<a href="01-home.php">Home</a>
95102
<ul class="sub-menu">
96-
<li class="menu-item"><a href="#">Sub menu item</a></li>
103+
<li class="menu-item"><a href="00-buttons.php">StyleGuide - Buttons</a></li>
104+
<li class="menu-item"><a href="00-cards.php">StyleGuide - Cards</a></li>
97105
</ul>
98106
</li>
99107
<li class="menu-item"><a href="02-page-default.php">Page default</a></li>

0 commit comments

Comments
 (0)