Skip to content

Commit

Permalink
Add Font Awesome; split Individual page; resolve absolute paths to fi…
Browse files Browse the repository at this point in the history
…x PostCSS build
  • Loading branch information
jchue committed Jun 21, 2022
1 parent f887b61 commit cb46dec
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 22 deletions.
7 changes: 5 additions & 2 deletions module.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace JChue\WebtreesThemes\Argon;

use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Module\MinimalTheme;
use Fisharebest\Webtrees\Module\ModuleCustomInterface;
use Fisharebest\Webtrees\Module\ModuleCustomTrait;
Expand All @@ -19,7 +20,7 @@
*/
public function title(): string
{
return 'Argon';
return I18N::translate('Argon');
}

/**
Expand Down Expand Up @@ -78,7 +79,8 @@ public function boot(): void
/**
* Individual Page
*/
View::registerCustomView('::individual-page', $this->name() . '::individual-page'); // Individual page template
View::registerCustomView('::individual-page-images', $this->name() . '::individual-page-images'); // Individual page thumbnails
View::registerCustomView('::individual-page-tabs', $this->name() . '::individual-page-tabs'); // Individual page tabs
View::registerCustomView('::modules/relatives/family', $this->name() . '::modules/relatives/family'); // Individual > Families tab
View::registerCustomView('::modules/stories/tab', $this->name() . '::modules/stories/tab'); // Individual > Stories tab
View::registerCustomView('::modules/lightbox/tab', $this->name() . '::modules/lightbox/tab'); // Individual > Album tab
Expand Down Expand Up @@ -142,6 +144,7 @@ public function stylesheets(): array
// Only files in the /public/ folder will be accessible via the webserver.
// Since modules cannot copy their files to the /public/ folder, they need to provide them via a callback.
$stylesheets[] = $this->assetUrl('css/theme.css');
$stylesheets[] = $this->assetUrl('css/fontawesome.css');

return $stylesheets;
}
Expand Down
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev:clean": "rm -r resources/css/ resources/js/",
"dev:fonts": "cp node_modules/@fortawesome/fontawesome-free/css/all.min.css resources/css/fontawesome.css",
"dev:sass": "sass --load-path=node_modules --no-source-map src/scss/theme.scss resources/css/theme.css",
"dev:postcss": "postcss -r resources/css/*.css --verbose",
"dev:css": "chokidar \"src/scss/**/*.scss\" --verbose -c \"npm run dev:sass && npm run dev:postcss\"",
"dev:css": "npm run dev:fonts && chokidar \"src/scss/**/*.scss\" --verbose -c \"npm run dev:sass && npm run dev:postcss\"",
"dev:js": "babel src/js/ --watch -d resources/js/",
"dev": "npm run dev:clean; concurrently --prefix-colors \"bgBlue.bold,bgMagenta.bold\" \"npm:dev:css\" \"npm:dev:js\"",
"dev": "npm run dev:clean; mkdir resources/css; concurrently --prefix-colors \"bgBlue.bold,bgMagenta.bold\" \"npm:dev:css\" \"npm:dev:js\"",
"build:clean": "rm -r dist/",
"build:fonts": "cp node_modules/@fortawesome/fontawesome-free/css/all.min.css dist/resources/css/fontawesome.css",
"build:sass": "sass --load-path=node_modules --no-source-map --style=compressed src/scss/theme.scss dist/resources/css/theme.css",
"build:postcss": "postcss --env production -r dist/resources/css/*.css",
"build:css": "npm run build:sass && npm run build:postcss",
"build:css": "npm run build:sass && npm run build:fonts && npm run build:postcss",
"build:lint": "eslint src/js/",
"build:babel": "babel src/js/ -d dist/resources/js/",
"build:uglify": "uglifyjs dist/resources/js/script.js --compress --mangle -o dist/resources/js/script.js",
Expand All @@ -23,6 +25,7 @@
"@babel/cli": "^7.17.10",
"@babel/core": "^7.17.10",
"@babel/preset-env": "^7.17.10",
"@fortawesome/fontawesome-free": "^6.1.1",
"autoprefixer": "^10.4.7",
"chokidar-cli": "^3.0.0",
"concurrently": "^7.1.0",
Expand Down
8 changes: 7 additions & 1 deletion postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const path = require('node:path');

module.exports = (ctx) => ({
map: false,
plugins: {
Expand All @@ -10,9 +12,13 @@ module.exports = (ctx) => ({
}],
} : false,
'postcss-import': { path: ['src/scss'] },
/**
* TODO: Reconsider inlining font faces and instead defining them on page;
* would need to figure out how to exclude fontawesome.css from PostCSS processing
*/
'postcss-url': {
url: 'inline',
basePath: ['../../node_modules/leaflet/dist'],
basePath: [path.resolve('node_modules/leaflet/dist'), path.resolve('node_modules/@fortawesome/fontawesome-free/webfonts')],
},
},
});
7 changes: 7 additions & 0 deletions resources/views/individual-page-images.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

$view = view('::individual-page-images', get_defined_vars());

$view = preg_replace('/text-center/', 'text-center small"><a', $view); // Make "Add a media object" smaller

echo $view;
7 changes: 7 additions & 0 deletions resources/views/individual-page-tabs.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

$view = view('::individual-page-tabs', get_defined_vars());

$view = preg_replace('/nav-tabs/', 'nav-pills', $view); // Change tabs to pills

echo $view;
15 changes: 0 additions & 15 deletions resources/views/individual-page.phtml

This file was deleted.

2 changes: 1 addition & 1 deletion src/scss/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ table.tv_tree {

td,
tbody td {
border: none;
border: none !important; /* Override tr:first-child border-top */
padding: 0;
}

Expand Down

0 comments on commit cb46dec

Please sign in to comment.