Skip to content

Commit

Permalink
do not output css when silent mode is turned on
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Champion committed Mar 26, 2019
1 parent 81df2ec commit fa44e6a
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 16 deletions.
4 changes: 1 addition & 3 deletions main.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
$o-crossword-is-silent: true !default;
$o-buttons-is-silent: false;

@import "o-colors/main";
@import "o-grid/main";
@import "o-typography/main";
Expand All @@ -12,6 +10,7 @@ $o-buttons-is-silent: false;
@import "src/scss/base";
@import "src/scss/orientation";
@import "src/scss/print";
@import "src/scss/mobile";

@if ($o-crossword-is-silent == false) {
@include oCrosswordAll;
Expand All @@ -20,4 +19,3 @@ $o-buttons-is-silent: false;
$o-crossword-is-silent: true !global;
}

@import "src/scss/mobile";
10 changes: 5 additions & 5 deletions src/js/oCrossword.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ OCrossword.prototype.assemble = function assemble() {
this.rootEl.insertBefore(buttonRow, wrapper);

const resetButton = document.createElement('button');
resetButton.classList.add('o-crossword-reset', 'o-buttons', 'o-buttons--mono');
resetButton.classList.add('o-crossword-reset', 'o-buttons', 'o-crossword-button');
if(answersEmpty() || isAnswerVersion) {
resetButton.classList.add('hidden');
}
Expand All @@ -503,28 +503,28 @@ OCrossword.prototype.assemble = function assemble() {
buttonRow.appendChild(resetButton);

const toggleViewButtonAboveGrid = document.createElement('button');
toggleViewButtonAboveGrid.classList.add('o-crossword-mobile-toggle', 'o-buttons', 'o-buttons--mono');
toggleViewButtonAboveGrid.classList.add('o-crossword-mobile-toggle', 'o-buttons', 'o-crossword-button');
toggleViewButtonAboveGrid.textContent = isGridView?'List view':'Grid view';

this.addEventListener(toggleViewButtonAboveGrid, 'click', toggleMobileViews);
this.rootEl.insertBefore(toggleViewButtonAboveGrid, gridWrapper);

const toggleViewButtonTop = document.createElement('button');
toggleViewButtonTop.classList.add('o-crossword-mobile-toggle', 'o-buttons', 'o-buttons--mono');
toggleViewButtonTop.classList.add('o-crossword-mobile-toggle', 'o-buttons', 'o-crossword-button');
toggleViewButtonTop.textContent = isGridView?'List view':'Grid view';

this.addEventListener(toggleViewButtonTop, 'click', toggleMobileViews);
buttonRow.appendChild(toggleViewButtonTop);

const toggleColumnsButton = document.createElement('button');
toggleColumnsButton.classList.add('o-crossword-mobile-toggle', 'o-buttons', 'o-buttons--mono');
toggleColumnsButton.classList.add('o-crossword-mobile-toggle', 'o-buttons', 'o-crossword-button');
toggleColumnsButton.textContent = isSingleColumnView?'2 col':'1 col';

this.addEventListener(toggleColumnsButton, 'click', toggleColumnView);
buttonRow.appendChild(toggleColumnsButton);

const toggleViewButtonBottom = document.createElement('button');
toggleViewButtonBottom.classList.add('o-crossword-mobile-toggle', 'o-buttons', 'o-buttons--mono');
toggleViewButtonBottom.classList.add('o-crossword-mobile-toggle', 'o-buttons', 'o-crossword-button');
toggleViewButtonBottom.textContent = isGridView?'List view':'Grid view';

this.addEventListener(toggleViewButtonBottom, 'click', toggleMobileViews);
Expand Down
4 changes: 4 additions & 0 deletions src/scss/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
box-sizing: border-box;
}

.o-crossword-button {
@include oButtons($theme: "mono");
}

.hidden {
display: none;
}
Expand Down
4 changes: 4 additions & 0 deletions src/scss/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@
.#{$classname} {
@include oCrosswordBase;
}
@include _oCrosswordOrientation;
@include _oCrosswordPrint;
@include _oCrosswordMobile;

}
4 changes: 3 additions & 1 deletion src/scss/_mobile.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// sass-lint:disable no-vendor-prefixes
@media screen and (max-width: $break-phone) {
@mixin _oCrosswordMobile () {
@media screen and (max-width: $break-phone) {
.o-crossword table,
.o-crossword .o-crossword-grid-wrapper .o-crossword-magic-input {
font-size: 1.2rem;
Expand Down Expand Up @@ -57,4 +58,5 @@
}
}
}
}
}
14 changes: 8 additions & 6 deletions src/scss/_orientation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
//below forces portrait mode on mobile phones
//it uses "min-aspect-ratio" to detect landscape,
//since keyboard popping will make "orientation" wrong in some cases
@media screen and (min-aspect-ratio: 13/9) and (max-width: $break-phone) {
body:not(.iOS) #main-container {
transform: rotate(-90deg);
width: 100% /* screen width */ ;
height: 100% /* screen height */ ;
overflow: scroll;
@mixin _oCrosswordOrientation () {
@media screen and (min-aspect-ratio: 13/9) and (max-width: $break-phone) {
body:not(.iOS) #main-container {
transform: rotate(-90deg);
width: 100% /* screen width */ ;
height: 100% /* screen height */ ;
overflow: scroll;
}
}
}
4 changes: 3 additions & 1 deletion src/scss/_print.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// sass-lint:disable no-qualifying-elements, no-important, no-vendor-prefixes
@media print {
@mixin _oCrosswordPrint () {
@media print {
@page {
margin: 1cm 0.5cm;
}
Expand Down Expand Up @@ -140,4 +141,5 @@
.o-crossword-reset {
display: none;
}
}
}

0 comments on commit fa44e6a

Please sign in to comment.