Skip to content

Commit

Permalink
Port assets to Webpack Encore
Browse files Browse the repository at this point in the history
Fixes #111
  • Loading branch information
TomaszGasior committed Sep 27, 2020
1 parent 631d363 commit 690f065
Show file tree
Hide file tree
Showing 35 changed files with 376 additions and 383 deletions.
File renamed without changes.
3 changes: 0 additions & 3 deletions assets/css/app.css

This file was deleted.

2 changes: 2 additions & 0 deletions assets/css/common.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@import './main.css';
@import './mobile.css' (max-width: 800px);
4 changes: 2 additions & 2 deletions public/assets/error.css → assets/css/error.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@font-face {
font-family: "LatoLatinWeb";
src: url('fonts/LatoLatin-Regular.woff2'), url('fonts/LatoLatin-Regular.woff');
src: url('../fonts/LatoLatin-Regular.woff2'), url('../fonts/LatoLatin-Regular.woff');
}

body {
Expand Down Expand Up @@ -31,7 +31,7 @@ div.logo {
}

div.logo a {
background: url('logo.svg') no-repeat;
background: url('../images/logo.svg') no-repeat;
background-size: contain;
height: 50px;
width: 200px;
Expand Down
10 changes: 5 additions & 5 deletions public/assets/main.css → assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

@font-face {
font-family: "LatoLatinWeb";
src: url('fonts/LatoLatin-Regular.woff2'), url('fonts/LatoLatin-Regular.woff');
src: url('../fonts/LatoLatin-Regular.woff2'), url('../fonts/LatoLatin-Regular.woff');
}
@font-face {
font-family: "LatoLatinWeb";
src: url('fonts/LatoLatin-Heavy.woff2');
src: url('../fonts/LatoLatin-Heavy.woff2');
font-weight: bold;
}
@font-face {
font-family: "LatoLatinWeb";
src: url('fonts/LatoLatin-Italic.woff2');
src: url('../fonts/LatoLatin-Italic.woff2');
font-style: italic;
}
@font-face {
font-family: "Inconsolata";
src: url('fonts/Inconsolata.woff2');
src: url('../fonts/Inconsolata.woff2');
}

body {
Expand Down Expand Up @@ -104,7 +104,7 @@ a:active {
}

.site-header .site-logo {
background: url('logo.svg') no-repeat;
background: url('../images/logo.svg') no-repeat;
background-size: 238px auto;
background-position: 4px 4px;
width: 245px;
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions public/assets/themes.css → assets/css/themes.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* theme — bieszczady */

.theme-bieszczady .customizable-background {
background: #E1E1E1 url('themes/bieszczady.jpg') no-repeat center / cover fixed;
background: #E1E1E1 url('../images/themes/bieszczady.jpg') no-repeat center / cover fixed;
}
.theme-bieszczady .customizable-color {
color: #000;
Expand All @@ -17,7 +17,7 @@
/* https://pixnio.com/textures-and-patterns/wood-texture/texture-old-retro-dirty-wood-knot */

.theme-wood .customizable-background {
background: #F2DAB6 url('themes/wood.jpg') no-repeat center / cover fixed;
background: #F2DAB6 url('../images/themes/wood.jpg') no-repeat center / cover fixed;
}
.theme-wood .customizable-color {
color: #000;
Expand All @@ -36,7 +36,7 @@
/* http://www.publicdomainpictures.net/view-image.php?image=25019&picture=dark-clouds-and-rainbow/ */

.theme-rainbow .customizable-background {
background: #D8DAD7 url('themes/rainbow.jpg') no-repeat center / cover fixed;
background: #D8DAD7 url('../images/themes/rainbow.jpg') no-repeat center / cover fixed;
}
.theme-rainbow .customizable-color {
color: #060015;
Expand All @@ -59,7 +59,7 @@
/* http://magdeleine.co/photo-by-caleb-ralston-n-491/ */

.theme-night .customizable-background {
background: #2A3944 url('themes/night.jpg') no-repeat center / cover fixed;
background: #2A3944 url('../images/themes/night.jpg') no-repeat center / cover fixed;
}
.theme-night .customizable-color {
color: #eee;
Expand Down
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
File renamed without changes
File renamed without changes
14 changes: 0 additions & 14 deletions assets/js/app.js

This file was deleted.

22 changes: 22 additions & 0 deletions assets/js/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import '../css/common.css';

import { SortableTable } from './src/SortableTable.js';
import { TabbedUI } from './src/TabbedUI.js';

document.documentElement.classList.add('JS');

document.addEventListener('DOMContentLoaded', () => {
let sortableTable = document.querySelector('table.sortable');
let tabbedUI = document.querySelector('.tabbed-ui');
let notification = document.querySelector('.notification-wrapper');

if (sortableTable) {
new SortableTable(sortableTable);
}
if (tabbedUI) {
new TabbedUI(tabbedUI);
}
if (notification) {
setTimeout(() => { notification.classList.add('hidden'); }, 10000);
}
});
9 changes: 9 additions & 0 deletions assets/js/radio-table-settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { RadioTableColumnsUI } from './src/RadioTableColumnsUI.js';

document.addEventListener('DOMContentLoaded', () => {
let container = document.querySelector('.radio-table-columns');

if (container) {
new RadioTableColumnsUI(container);
}
});
15 changes: 15 additions & 0 deletions assets/js/radio-table-show.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import '../css/themes.css';

import { NumberIndentManager } from './src/NumberIndentManager.js';
import { OverflowStylesManager } from './src/OverflowStylesManager.js';
import { RDSPopupManager } from './src/RDSPopupManager.js';

document.addEventListener('DOMContentLoaded', () => {
let container = document.querySelector('.radio-table-container');

if (container) {
new NumberIndentManager(container);
new OverflowStylesManager(container);
new RDSPopupManager(container);
}
});
59 changes: 59 additions & 0 deletions assets/js/src/NumberIndentManager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
export class NumberIndentManager
{
constructor(container)
{
this.container = container;
this.itemsGroups = new Map;

this.setupItemsGroups();
this.applyNumberIndent();
}

setupItemsGroups()
{
this.container.querySelectorAll('[data-number-indent]').forEach(item => {
let indentType = item.dataset.numberIndent;

if (!this.itemsGroups.has(indentType)) {
this.itemsGroups.set(indentType, []);
}

this.itemsGroups.get(indentType).push(item);
});
}

applyNumberIndent()
{
this.itemsGroups.forEach(items => {
let maxNumber = this.getMaxNumberFromItems(items);
let maxDigits = this.getDigitsCountOfInteger(maxNumber);

items.forEach(item => {
let number = this.getIntegerFromItem(item);
let digits = this.getDigitsCountOfInteger(number);
let digitsDifference = maxDigits - digits;

if (digitsDifference) {
item.classList.add(`number-indent-${digitsDifference}`);
}
});
});
}

getIntegerFromItem(item)
{
return Number.parseInt(item.textContent);
}

getDigitsCountOfInteger(number)
{
return number.toString().length;
}

getMaxNumberFromItems(items)
{
let numbers = items.map(item => this.getIntegerFromItem(item));

return numbers.reduce((prev, value) => prev > value ? prev : value);
}
}
32 changes: 32 additions & 0 deletions assets/js/src/OverflowStylesManager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export class OverflowStylesManager
{
constructor(container)
{
this.container = container;

this.refreshStatus();

this.container.addEventListener('scroll', this.refreshStatus.bind(this));
window.addEventListener('resize', this.refreshStatus.bind(this));
}

refreshStatus()
{
const MIN_SCROLL_MARGIN = 3;

let container = this.container;
let isScrollbarVisible = (container.scrollWidth !== container.clientWidth);

container.classList.remove('overflow-left');
container.classList.remove('overflow-right');

if (isScrollbarVisible) {
if(container.scrollLeft > MIN_SCROLL_MARGIN) {
container.classList.add('overflow-left');
}
if((container.scrollWidth - container.clientWidth - container.scrollLeft) > MIN_SCROLL_MARGIN) {
container.classList.add('overflow-right');
}
}
}
}
105 changes: 1 addition & 104 deletions public/assets/radio-table.js → assets/js/src/RDSPopupManager.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class RDSPopupManager
export class RDSPopupManager
{
constructor(container)
{
Expand Down Expand Up @@ -150,106 +150,3 @@ class RDSPopupManager
this.hidePopup();
}
}

class NumberIndentManager
{
constructor(container)
{
this.container = container;
this.itemsGroups = new Map;

this.setupItemsGroups();
this.applyNumberIndent();
}

setupItemsGroups()
{
this.container.querySelectorAll('[data-number-indent]').forEach(item => {
let indentType = item.dataset.numberIndent;

if (!this.itemsGroups.has(indentType)) {
this.itemsGroups.set(indentType, []);
}

this.itemsGroups.get(indentType).push(item);
});
}

applyNumberIndent()
{
this.itemsGroups.forEach(items => {
let maxNumber = this.getMaxNumberFromItems(items);
let maxDigits = this.getDigitsCountOfInteger(maxNumber);

items.forEach(item => {
let number = this.getIntegerFromItem(item);
let digits = this.getDigitsCountOfInteger(number);
let digitsDifference = maxDigits - digits;

if (digitsDifference) {
item.classList.add(`number-indent-${digitsDifference}`);
}
});
});
}

getIntegerFromItem(item)
{
return Number.parseInt(item.textContent);
}

getDigitsCountOfInteger(number)
{
return number.toString().length;
}

getMaxNumberFromItems(items)
{
let numbers = items.map(item => this.getIntegerFromItem(item));

return numbers.reduce((prev, value) => prev > value ? prev : value);
}
}

class OverflowStylesManager
{
constructor(container)
{
this.container = container;

this.refreshStatus();

this.container.addEventListener('scroll', this.refreshStatus.bind(this));
window.addEventListener('resize', this.refreshStatus.bind(this));
}

refreshStatus()
{
const MIN_SCROLL_MARGIN = 3;

let container = this.container;
let isScrollbarVisible = (container.scrollWidth !== container.clientWidth);

container.classList.remove('overflow-left');
container.classList.remove('overflow-right');

if (isScrollbarVisible) {
if(container.scrollLeft > MIN_SCROLL_MARGIN) {
container.classList.add('overflow-left');
}
if((container.scrollWidth - container.clientWidth - container.scrollLeft) > MIN_SCROLL_MARGIN) {
container.classList.add('overflow-right');
}
}
}
}

document.addEventListener('DOMContentLoaded', function(){
let container = document.querySelector('.radio-table-container');

if (container) {
new NumberIndentManager(container);
new OverflowStylesManager(container);
new RDSPopupManager(container);
}
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class RadioTableColumnsUI
export class RadioTableColumnsUI
{
constructor(container)
{
Expand Down Expand Up @@ -154,11 +154,3 @@ class RadioTableColumnsUI
button.focus();
}
}

document.addEventListener('DOMContentLoaded', function(){
let container = document.querySelector('.radio-table-columns');

if (container) {
new RadioTableColumnsUI(container);
}
});
Loading

0 comments on commit 690f065

Please sign in to comment.