Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
bef2045
Embedded css sources for easier firefox dev work
ssddanbrown May 12, 2022
221d910
Reduced excess margin in chapter contents lists
ssddanbrown May 12, 2022
a0fe614
Improved the display of dropdown menus
ssddanbrown May 13, 2022
24b31b6
Cleaned up entity details listing
ssddanbrown May 13, 2022
60e319c
Tidied up book navigation styles
ssddanbrown May 13, 2022
e6864a9
Improved card list design
ssddanbrown May 14, 2022
2c74dfd
Updated breadcrumb dropdown styles, improved keyboard nav
ssddanbrown May 14, 2022
89dfa43
Fixed loading animation delay
ssddanbrown May 14, 2022
35a47a2
Added animation transition for breadcrumb dropdown load
ssddanbrown May 14, 2022
78920d7
Updated tri-layout sidebars to not be cut-off by padding
ssddanbrown May 14, 2022
6fa699a
Fixed skip-to-content link shadow being slightly visible
ssddanbrown May 14, 2022
9fda0df
Updated dropdown search boxe positions to align with other dropdowns
ssddanbrown May 14, 2022
d20c74b
Improved input size consistency
ssddanbrown May 14, 2022
340c9ec
Fixed some inputs affected by height changes
ssddanbrown May 17, 2022
4866a3a
Refined header bar styles
ssddanbrown May 17, 2022
cb1c2db
Aligned collapsed header dropdown item styles
ssddanbrown May 17, 2022
4759fa1
Made the "Custom HTML Head Content" setting a highlighted code editor
ssddanbrown May 17, 2022
b030c13
Tweaked chapter list item styles
ssddanbrown May 18, 2022
eeccc2e
Readjusted book child item styles after other changes
ssddanbrown May 18, 2022
cb10ad8
Made chapter toggle in book sidebar nav more consistent
ssddanbrown May 18, 2022
2b817e7
Updated attachment links to have dropdown for open type
ssddanbrown May 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"private": true,
"scripts": {
"build:css:dev": "sass ./resources/sass:./public/dist",
"build:css:watch": "sass ./resources/sass:./public/dist --watch",
"build:css:dev": "sass ./resources/sass:./public/dist --embed-sources",
"build:css:watch": "sass ./resources/sass:./public/dist --watch --embed-sources",
"build:css:production": "sass ./resources/sass:./public/dist -s compressed",
"build:js:dev": "node dev/build/esbuild.js",
"build:js:watch": "chokidar --initial \"./resources/**/*.js\" -c \"npm run build:js:dev\"",
Expand Down
1 change: 1 addition & 0 deletions resources/icons/download.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions resources/js/code.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,21 @@ export function popupEditor(elem, modeSuggestion) {
});
}

/**
* Create an inline editor to replace the given textarea.
* @param {HTMLTextAreaElement} textArea
* @param {String} mode
* @returns {CodeMirror3}
*/
export function inlineEditor(textArea, mode) {
return CodeMirror.fromTextArea(textArea, {
mode: getMode(mode, textArea.value),
lineNumbers: true,
lineWrapping: false,
theme: getTheme(),
});
}

/**
* Set the mode of a codemirror instance.
* @param cmInstance
Expand Down
37 changes: 37 additions & 0 deletions resources/js/components/chapter-contents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {slideUp, slideDown} from "../services/animations";

/**
* @extends {Component}
*/
class ChapterContents {

setup() {
this.list = this.$refs.list;
this.toggle = this.$refs.toggle;

this.isOpen = this.toggle.classList.contains('open');
this.toggle.addEventListener('click', this.click.bind(this));
}

open() {
this.toggle.classList.add('open');
this.toggle.setAttribute('aria-expanded', 'true');
slideDown(this.list, 180);
this.isOpen = true;
}

close() {
this.toggle.classList.remove('open');
this.toggle.setAttribute('aria-expanded', 'false');
slideUp(this.list, 180);
this.isOpen = false;
}

click(event) {
event.preventDefault();
this.isOpen ? this.close() : this.open();
}

}

export default ChapterContents;
33 changes: 0 additions & 33 deletions resources/js/components/chapter-toggle.js

This file was deleted.

16 changes: 16 additions & 0 deletions resources/js/components/code-textarea.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* A simple component to render a code editor within the textarea
* this exists upon.
* @extends {Component}
*/
class CodeTextarea {

async setup() {
const mode = this.$opts.mode;
const Code = await window.importVersioned('code');
Code.inlineEditor(this.$el, mode);
}

}

export default CodeTextarea;
3 changes: 3 additions & 0 deletions resources/js/components/dropdown-search.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {debounce} from "../services/util";
import {transitionHeight} from "../services/animations";

class DropdownSearch {

Expand Down Expand Up @@ -51,7 +52,9 @@ class DropdownSearch {

try {
const resp = await window.$http.get(this.getAjaxUrl(searchTerm));
const animate = transitionHeight(this.listContainerElem, 80);
this.listContainerElem.innerHTML = resp.data;
animate();
} catch (err) {
console.error(err);
}
Expand Down
32 changes: 24 additions & 8 deletions resources/js/components/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,31 @@ class DropDown {
this.menu.classList.add('anim', 'menuIn');
this.toggle.setAttribute('aria-expanded', 'true');

const menuOriginalRect = this.menu.getBoundingClientRect();
let heightOffset = 0;
const toggleHeight = this.toggle.getBoundingClientRect().height;
const dropUpwards = menuOriginalRect.bottom > window.innerHeight;

// If enabled, Move to body to prevent being trapped within scrollable sections
if (this.moveMenu) {
// Move to body to prevent being trapped within scrollable sections
this.rect = this.menu.getBoundingClientRect();
this.body.appendChild(this.menu);
this.menu.style.position = 'fixed';
if (this.direction === 'right') {
this.menu.style.right = `${(this.rect.right - this.rect.width)}px`;
this.menu.style.right = `${(menuOriginalRect.right - menuOriginalRect.width)}px`;
} else {
this.menu.style.left = `${this.rect.left}px`;
this.menu.style.left = `${menuOriginalRect.left}px`;
}
this.menu.style.top = `${this.rect.top}px`;
this.menu.style.width = `${this.rect.width}px`;
this.menu.style.width = `${menuOriginalRect.width}px`;
heightOffset = dropUpwards ? (window.innerHeight - menuOriginalRect.top - toggleHeight / 2) : menuOriginalRect.top;
}

// Adjust menu to display upwards if near the bottom of the screen
if (dropUpwards) {
this.menu.style.top = 'initial';
this.menu.style.bottom = `${heightOffset}px`;
} else {
this.menu.style.top = `${heightOffset}px`;
this.menu.style.bottom = 'initial';
}

// Set listener to hide on mouse leave or window click
Expand Down Expand Up @@ -74,18 +87,21 @@ class DropDown {
this.menu.style.display = 'none';
this.menu.classList.remove('anim', 'menuIn');
this.toggle.setAttribute('aria-expanded', 'false');
this.menu.style.top = '';
this.menu.style.bottom = '';

if (this.moveMenu) {
this.menu.style.position = '';
this.menu.style[this.direction] = '';
this.menu.style.top = '';
this.menu.style.width = '';
this.container.appendChild(this.menu);
}

this.showing = false;
}

getFocusable() {
return Array.from(this.menu.querySelectorAll('[tabindex],[href],button,input:not([type=hidden])'));
return Array.from(this.menu.querySelectorAll('[tabindex]:not([tabindex="-1"]),[href],button,input:not([type=hidden])'));
}

focusNext() {
Expand Down
6 changes: 4 additions & 2 deletions resources/js/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import attachmentsList from "./attachments-list.js"
import autoSuggest from "./auto-suggest.js"
import backToTop from "./back-to-top.js"
import bookSort from "./book-sort.js"
import chapterToggle from "./chapter-toggle.js"
import chapterContents from "./chapter-contents.js"
import codeEditor from "./code-editor.js"
import codeHighlighter from "./code-highlighter.js"
import codeTextarea from "./code-textarea.js"
import collapsible from "./collapsible.js"
import confirmDialog from "./confirm-dialog"
import customCheckbox from "./custom-checkbox.js"
Expand Down Expand Up @@ -62,9 +63,10 @@ const componentMapping = {
"auto-suggest": autoSuggest,
"back-to-top": backToTop,
"book-sort": bookSort,
"chapter-toggle": chapterToggle,
"chapter-contents": chapterContents,
"code-editor": codeEditor,
"code-highlighter": codeHighlighter,
"code-textarea": codeTextarea,
"collapsible": collapsible,
"confirm-dialog": confirmDialog,
"custom-checkbox": customCheckbox,
Expand Down
36 changes: 34 additions & 2 deletions resources/js/services/animations.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function slideUp(element, animTime = 400) {
const currentPaddingTop = computedStyles.getPropertyValue('padding-top');
const currentPaddingBottom = computedStyles.getPropertyValue('padding-bottom');
const animStyles = {
height: [`${currentHeight}px`, '0px'],
maxHeight: [`${currentHeight}px`, '0px'],
overflow: ['hidden', 'hidden'],
paddingTop: [currentPaddingTop, '0px'],
paddingBottom: [currentPaddingBottom, '0px'],
Expand All @@ -73,7 +73,7 @@ export function slideDown(element, animTime = 400) {
const targetPaddingTop = computedStyles.getPropertyValue('padding-top');
const targetPaddingBottom = computedStyles.getPropertyValue('padding-bottom');
const animStyles = {
height: ['0px', `${targetHeight}px`],
maxHeight: ['0px', `${targetHeight}px`],
overflow: ['hidden', 'hidden'],
paddingTop: ['0px', targetPaddingTop],
paddingBottom: ['0px', targetPaddingBottom],
Expand All @@ -82,6 +82,38 @@ export function slideDown(element, animTime = 400) {
animateStyles(element, animStyles, animTime);
}

/**
* Transition the height of the given element between two states.
* Call with first state, and you'll receive a function in return.
* Call the returned function in the second state to animate between those two states.
* If animating to/from 0-height use the slide-up/slide down as easier alternatives.
* @param {Element} element - Element to animate
* @param {Number} animTime - Animation time in ms
* @returns {function} - Function to run in second state to trigger animation.
*/
export function transitionHeight(element, animTime = 400) {
const startHeight = element.getBoundingClientRect().height;
const initialComputedStyles = getComputedStyle(element);
const startPaddingTop = initialComputedStyles.getPropertyValue('padding-top');
const startPaddingBottom = initialComputedStyles.getPropertyValue('padding-bottom');

return () => {
cleanupExistingElementAnimation(element);
const targetHeight = element.getBoundingClientRect().height;
const computedStyles = getComputedStyle(element);
const targetPaddingTop = computedStyles.getPropertyValue('padding-top');
const targetPaddingBottom = computedStyles.getPropertyValue('padding-bottom');
const animStyles = {
height: [`${startHeight}px`, `${targetHeight}px`],
overflow: ['hidden', 'hidden'],
paddingTop: [startPaddingTop, targetPaddingTop],
paddingBottom: [startPaddingBottom, targetPaddingBottom],
};

animateStyles(element, animStyles, animTime);
};
}

/**
* Animate the css styles of an element using FLIP animation techniques.
* Styles must be an object where the keys are style properties, camelcase, and the values
Expand Down
2 changes: 2 additions & 0 deletions resources/lang/en/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
'previous' => 'Previous',
'filter_active' => 'Active Filter:',
'filter_clear' => 'Clear Filter',
'download' => 'Download',
'open_in_tab' => 'Open in Tab',

// Sort Options
'sort_options' => 'Sort Options',
Expand Down
1 change: 0 additions & 1 deletion resources/sass/_blocks.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
@include lightDark(background-color, #FFF, #222);
box-shadow: $bs-card;
border-radius: 3px;
border: 1px solid transparent;
.body, p.empty-text {
padding: $-m;
}
Expand Down
Loading