-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✅ Closes: #22
- Loading branch information
Showing
15 changed files
with
217 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<!DOCTYPE html> | ||
<html class="ph" lang="en"> | ||
<head> | ||
<title>@phun-ky/speccer</title> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="Content-Language" content="no" /> | ||
<meta name="robots" content="none" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="application-name" content="@phun-ky/speccer" /> | ||
<style type="text/css"></style> | ||
</head> | ||
<body class="ph"> | ||
<div | ||
data-anatomy-section | ||
class="ph container" | ||
style=" | ||
position: relative; | ||
padding: 5rem; | ||
display: grid; | ||
grid-template-columns: repeat(5, 160px); | ||
grid-template-rows: repeat(8, 160px); | ||
grid-auto-flow: dense; | ||
grid-gap: 2rem 2rem; | ||
" | ||
> | ||
<div data-speccer-mark style="grid-column: span 4" class="ph box"></div> | ||
<div data-speccer-mark class="ph box"></div> | ||
<div data-speccer-mark style="grid-column: span 2" class="ph box"></div> | ||
<div data-speccer-mark class="ph box"></div> | ||
<div data-speccer-mark class="ph box"></div> | ||
<div data-speccer-mark class="ph box"></div> | ||
</div> | ||
|
||
<link async href="/speccer.css" rel="stylesheet" type="text/css" /> | ||
<link | ||
async | ||
href="https://fonts.googleapis.com/css?family=Lato:300,300i,400,400i,700,700i,900,900i&display=swap&subset=latin-ext" | ||
rel="stylesheet" | ||
type="text/css" | ||
/> | ||
<link | ||
async | ||
href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i,800,800i&display=swap&subset=latin-ext" | ||
rel="stylesheet" | ||
type="text/css" | ||
/> | ||
<style type="text/css"> | ||
body.ph { | ||
background-color: #f5f5f5; | ||
} | ||
.ph.container { | ||
counter-reset: box; | ||
} | ||
.ph.box { | ||
background-color: white; | ||
min-height: 160px; | ||
min-width: 160px; | ||
margin: 0; | ||
padding: 2rem; | ||
border: 1pt solid rgba(51, 51, 51, 0.1); | ||
color: #4d4d4d; | ||
font-family: Lato, sans-serif; | ||
font-size: 4rem; | ||
box-sizing: border-box; | ||
box-shadow: 0 0 10px rgba(51, 51, 51, 0.2); | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
.ph.box:after { | ||
counter-increment: box; | ||
content: counter(box); | ||
} | ||
</style> | ||
|
||
<script data-manual src="/speccer.js" type="text/javascript"></script> | ||
<script> | ||
if (document.readyState === 'loading') { | ||
document.addEventListener('DOMContentLoaded', window.speccer); | ||
} else { | ||
// `DOMContentLoaded` already fired | ||
window.speccer(); | ||
} | ||
const debounce = function (func, wait, immediate) { | ||
var timeout; | ||
return function () { | ||
var context = this, | ||
args = arguments; | ||
var later = function () { | ||
timeout = null; | ||
if (!immediate) func.apply(context, args); | ||
}; | ||
var callNow = immediate && !timeout; | ||
clearTimeout(timeout); | ||
timeout = setTimeout(later, wait); | ||
if (callNow) func.apply(context, args); | ||
}; | ||
}; | ||
const speccerEventFunc = debounce(() => { | ||
window.speccer(); | ||
}, 100); | ||
|
||
window.removeEventListener('resize', speccerEventFunc); | ||
window.addEventListener('resize', speccerEventFunc); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.ph.speccer.mark | ||
background-color var(--ph-speccer-mark-background-color) | ||
border-color var(--ph-speccer-mark-border-color) | ||
border-width 1px | ||
border-style solid | ||
position absolute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* eslint no-console:0 */ | ||
'use strict'; | ||
|
||
import * as styles from '../lib/styles'; | ||
import { cx, set } from '../lib/classnames'; | ||
import { getRec } from 'lib/position'; | ||
|
||
export const create = (n = 'span') => { | ||
const markElement = document.createElement(n); | ||
const classNames = cx('ph speccer mark'); | ||
|
||
set(markElement, classNames); | ||
|
||
return markElement; | ||
}; | ||
|
||
export const element = async (elementToMark: HTMLElement) => { | ||
if (!elementToMark) return Promise.resolve(); | ||
|
||
const markElement = create(); | ||
|
||
document.body.appendChild(markElement); | ||
|
||
const positionalStyles = await getRec(markElement, elementToMark); | ||
const { left, top, height, width } = positionalStyles.absolute(); | ||
const markStyles = { | ||
left: `${left}px`, | ||
top: `${top}px`, | ||
height: `${height}px`, | ||
width: `${width}px` | ||
}; | ||
|
||
await styles.add(markElement, markStyles); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters