Skip to content

Commit

Permalink
Merge pull request #55 from royalfig/feature/headings
Browse files Browse the repository at this point in the history
Feature/headings
  • Loading branch information
royalfig authored May 7, 2021
2 parents 92ffb16 + 74e17ca commit 1495050
Show file tree
Hide file tree
Showing 29 changed files with 87 additions and 166 deletions.
2 changes: 1 addition & 1 deletion assets/built/app.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/built/app.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/built/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/built/app.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion assets/built/critical.css.map

This file was deleted.

2 changes: 1 addition & 1 deletion assets/built/post.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/built/post.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/built/post.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/built/post.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion default.hbs

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions helpers/inline-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ async function injectCss() {
.replace('{{!-- critical-css --}}', `<style>${css.toString()}</style>`);
await writeFile('./default.hbs', inlinedCss.toString());

unlink(path.join(process.cwd(), '/assets/built/critical.css'), (err) => {
if (err) {
console.log(err);
}
});
unlink(path.join(process.cwd(), '/assets/built/critical.css'))
.then(() => console.log('deleted'))
.catch((err) => console.log(err));

unlink(path.join(process.cwd(), '/assets/built/critical.css.map'))
.then(() => console.log('deleted'))
.catch((err) => console.log(err));

console.log('🥳 Inlined critical css');
}
Expand Down
2 changes: 1 addition & 1 deletion home.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ into the {body} of the default.hbs template --}}
<div class="sm-main__inner-container">
<h2 class="sm-main__header">Featured</h2>
<section class="sm-grid-container">
{{#foreach featured}}
{{#foreach featured limit="10"}}
{{> "card"}}
{{/foreach}}
</section>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "smart",
"version": "1.1.0",
"version": "1.1.1",
"description": "A customizable Ghost theme",
"main": "index.js",
"engines": {
Expand Down
28 changes: 26 additions & 2 deletions partials/navbar.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,32 @@
{{/foreach}}
{{else}}
{{#post}}
{{!-- TODO Put share menu here? --}}
{{#link href="#sm-main" class="sm-navbar__new-link"}}{{title}}{{/link}}
<span class="sm-navbar__new-tag--text">Share</span>
<a class="sm-post-share-bar__link--twitter"
href="https://twitter.com/share?url={{url absolute='true'}}&amp;text={{#if title}}{{title}}{{else}}{{name}}{{/if}}"
aria-label="Share on Twitter" target="_blank" rel="noopener noreferrer">
<svg>
<use href="#twitter"></use>
</svg>
</a>
<a class="sm-post-share-bar__link--facebook" href="http://www.facebook.com/sharer.php?u={{url absolute='true'}}"
aria-label="Share on Facebook" target="_blank" rel="noopener noreferrer">
<svg>
<use href="#facebook"></use>
</svg>
</a>
<a class="sm-post-share-bar__link--linkedin" data-tt="Share on LinkedIn"
href="http://www.linkedin.com/shareArticle?mini=true&amp;url={{url absolute='true'}}"
aria-label="Share on LinkedIn" target="_blank" rel="noopener noreferrer">
<svg>
<use href="#linkedin"></use>
</svg>
</a>
<button class="sm-post-share-bar__link--copy" aria-label="Copy to clipboard">
<svg>
<use href="#copy"></use>
</svg>
</button>
{{/post}}
{{/is}}
</div>
Expand Down
9 changes: 5 additions & 4 deletions partials/share.hbs
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
<aside class="sm-post-share-bar">
<span class="sm-navbar__new-tag--text">Share</span>
<a class="sm-post-share-bar__link--twitter"
href="https://twitter.com/share?url={{url absolute='true'}}&amp;text={{#if title}}{{title}}{{else}}{{name}}{{/if}}"
aria-label="Share on Twitter">
aria-label="Share on Twitter" target="_blank" rel="noopener noreferrer">
<svg>
<use href="#twitter"></use>
</svg>
</a>
<a class="sm-post-share-bar__link--facebook" href="http://www.facebook.com/sharer.php?u={{url absolute='true'}}"
aria-label="Share on Facebook">
aria-label="Share on Facebook" target="_blank" rel="noopener noreferrer">
<svg>
<use href="#facebook"></use>
</svg>
</a>
<a class="sm-post-share-bar__link--linkedin" data-tt="Share on LinkedIn"
href="http://www.linkedin.com/shareArticle?mini=true&amp;url={{url absolute='true'}}"
aria-label="Share on LinkedIn">
aria-label="Share on LinkedIn" target="_blank" rel="noopener noreferrer">
<svg>
<use href="#linkedin"></use>
</svg>
</a>
<button class="sm-post-share-bar__link--copy" id="sm-copy-button" aria-label="Copy to clipboard">
<button class="sm-post-share-bar__link--copy" aria-label="Copy to clipboard">
<svg>
<use href="#copy"></use>
</svg>
Expand Down
6 changes: 1 addition & 5 deletions post.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
{{!-- The tag above means: insert everything in this file
into the {body} of the default.hbs template --}}

{{! Post Reading Progress }}
<div class="sm-post-reading-progress"></div>
{{! Post Reading Progress }}

{{#post}}

{{!-- Post Header --}}
Expand Down Expand Up @@ -177,7 +173,7 @@ into the {body} of the default.hbs template --}}
</div>
{{/next_post}}

{{#get "posts" include="tags" limit="2" filter="primary_tag:-{{primary_tag.slug}}+id:-{{id}}"}}
{{#get "posts" include="tags" limit="2" filter="id:-{{id}}+primary_tag:-{{primary_tag.slug}}"}}
{{#foreach posts}}
<div class="sm-related-posts sm-related-posts-3-{{@number}}">
{{> "card"}}
Expand Down
3 changes: 0 additions & 3 deletions src/js/app/focusTrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ const getNonHiddenLastEl = (el) => {
return penultimateEl;
};

// Need to run a function that runs when modal opens and sets focus
// Need to run a different function to handle keypresses

const configureFocusableElements = (containerEl) => {
const focusableEl = containerEl.querySelectorAll(FOCUSABLE_EL);
focusableEl.forEach((el) => el.setAttribute('tabindex', '0'));
Expand Down
3 changes: 0 additions & 3 deletions src/js/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import colorMode from './colorModeToggle';
import grid from './grid';
import modalFn from './modal';
import search from './search';
import toast from './toast';
import 'lazysizes';

setTabIndex();
Expand All @@ -16,5 +15,3 @@ modalFn();
if (typeof SEARCH_API !== 'undefined') {
search();
}

toast();
5 changes: 0 additions & 5 deletions src/js/app/setTabIndex.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
/*
* Remove menu nav links from the DOM
*/

export default function removeNavLinks() {
const menuNavLinks = document.querySelectorAll('#menu a');

menuNavLinks.forEach((el) => el.setAttribute('tabindex', '-1'));
}
28 changes: 15 additions & 13 deletions src/js/post/copy.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
//-------------------------------------------
// Copy Function
//-------------------------------------------
const copyButton = document.getElementById('sm-copy-button');
const toast = require('./toast');

const copyButtons = document.querySelectorAll('.sm-post-share-bar__link--copy');

export default function copyInit() {
if (copyButton) {
copyButton.addEventListener('click', () => {
const url = window.location.href;
const temp = document.createElement('input');
document.body.appendChild(temp);
temp.value = url;
temp.select();
document.execCommand('copy');
document.body.removeChild(temp);
if (copyButtons.length) {
copyButtons.forEach((el) => {
el.addEventListener('click', () => {
const url = window.location.href;
const temp = document.createElement('input');
document.body.appendChild(temp);
temp.value = url;
temp.select();
document.execCommand('copy');
document.body.removeChild(temp);
toast('Link copied to clipboard');
});
});
}
}
2 changes: 0 additions & 2 deletions src/js/post/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import '../../scss/post.scss';

import initMediumZoom from './medium_zoom';
import fluidvids from './fluidvids';
import shareProgressInit from './progress_and_share';
import copyInit from './copy';
import responsiveTableInit from './responsiveTables';

initMediumZoom();
fluidvids();
shareProgressInit();
copyInit();
responsiveTableInit();
Empty file.
67 changes: 0 additions & 67 deletions src/js/post/progress_and_share.js

This file was deleted.

13 changes: 1 addition & 12 deletions src/js/app/toast.js → src/js/post/toast.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const copyBtn = document.getElementById('sm-copy-button');

const destroyToast = (el) => {
el.classList.add('sm-toast__slide-out');
setTimeout(() => {
Expand All @@ -14,7 +12,7 @@ const checkDomForToast = () => {
}
};

const createToast = (value) => {
module.exports = function createToast(value) {
checkDomForToast();
const container = document.createElement('div');
container.classList.add('sm-toast');
Expand All @@ -27,12 +25,3 @@ const createToast = (value) => {
document.body.append(container);
setTimeout(destroyToast.bind(null, container), 3000);
};

export default function toast() {
if (copyBtn) {
copyBtn.addEventListener(
'click',
createToast.bind(null, 'Link copied to clipboard')
);
}
}
2 changes: 1 addition & 1 deletion src/scss/abstracts/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ $mono: 'JetBrains Mono', 'Roboto Mono', 'IBM Plex Mono', 'Cascadia Code',
//-------------------------------------------

// Breakpoints
$tablet: 640px;
$tablet: 600px;
$laptop: 1024px;
$desktop: 1280px;

Expand Down
26 changes: 11 additions & 15 deletions src/scss/components/_share.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
@include mixins.color-map(color, text2);
text-align: center;
@include mixins.color-map(background-color, surface3);
border-bottom: 3px solid var(--text4);
opacity: 0;
transition: transform 0.2s ease-in, opacity 0.2s;
transform: translate3d(0, 100%, 0);
border-bottom: 3px solid var(--surface4);

@media (min-width: variables.$laptop) {
display: none;
}

&__link {
width: 2.5rem;
Expand All @@ -37,6 +38,12 @@
@include mixins.color-map(stroke, text2);
@include mixins.transition(stroke);
}

@media (min-width: variables.$laptop) {
width: 1.8rem;
height: 1.8rem;
padding: 0.36rem;
}
}

&__link--twitter {
Expand Down Expand Up @@ -88,15 +95,4 @@
}
}
}

@include mixins.respond-above(variables.$laptop) {
top: 50%;
bottom: initial;
flex-direction: column;
width: initial;
border-bottom: none;
border-top-right-radius: variables.$radius;
border-bottom-right-radius: variables.$radius;
transform: translate3d(-100%, -50%, 0);
}
}
6 changes: 6 additions & 0 deletions src/scss/layout/_navbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@
border-radius: variables.$radius;
@include mixins.color-map(color, textInverse);
@include mixins.color-map(background-color, secondary);

&--text {
@extend .sm-navbar__new-tag;
color: var(--text2);
background: none;
}
}

&__new-link {
Expand Down
15 changes: 0 additions & 15 deletions src/scss/pages/_post.scss
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
@use '../abstracts/variables';
@use '../abstracts/mixins';
@use '../components/link';
//-------------------------------------------
// Post Reading Progress Bar
//-------------------------------------------
.sm-post-reading-progress {
position: fixed;
top: 0;
z-index: 6;
width: 0;
max-width: 100%;
height: 3px;
@include mixins.color-map(background-color, text4);
border-top-right-radius: variables.$radius;
border-bottom-right-radius: variables.$radius;
transition: all 0.1s ease;
}

//-------------------------------------------
// Post Styles
Expand Down
Loading

0 comments on commit 1495050

Please sign in to comment.