Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Artboard #458

Draft
wants to merge 63 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
0ba4ef7
minimal POC
argyleink May 7, 2020
5197945
basic hovers work
argyleink May 8, 2020
e93a12d
extension build works
argyleink May 8, 2020
4142d29
guides work with body transform, moving things to html
argyleink May 8, 2020
e59a508
fixes gridlines
argyleink May 10, 2020
63447b7
adds hotkey page zoom
argyleink May 10, 2020
f7df872
fixes hover
argyleink May 10, 2020
b8e2c4c
fixes handles
argyleink May 10, 2020
89cc25e
fixes measurements
argyleink May 10, 2020
9bb268b
patches margin and padding
argyleink May 10, 2020
bf31a26
fixes metatips
argyleink May 10, 2020
c75b4a6
spacing nit
argyleink May 10, 2020
8e75576
cmd works for all hotkeys, mousewheel working
argyleink May 11, 2020
840cc46
fixes cmd hotkeys not blocking defaults
argyleink May 12, 2020
bc2c83c
all zooms work together
argyleink May 12, 2020
6b5f55b
move logic into a feature module
argyleink May 12, 2020
e97a021
fixes select broken after zoom
argyleink May 12, 2020
0d2263d
zoom improvements
argyleink May 13, 2020
f7ceb37
export hide function
argyleink May 15, 2020
1f812f4
hide grids on zoom
argyleink May 15, 2020
d1cff92
smooth scroll after hotkey zooms
argyleink May 15, 2020
8654227
more adaptive background setup
argyleink May 15, 2020
1b64cfd
fixes sites with not html or body bg
argyleink May 15, 2020
5bddc2f
switch to waapi to fix finished bug and do a little cleanup
argyleink May 21, 2020
0544891
Merge branch 'artboard' of https://github.com/GoogleChromeLabs/Projec…
argyleink May 21, 2020
efded95
inline the await
argyleink May 21, 2020
cb19604
update ux for zoom sensitivity
argyleink May 23, 2020
c682184
fixes more elements appending inside body
argyleink May 23, 2020
b776d7f
DRYed it up
argyleink May 23, 2020
2d0bf49
more drying
argyleink May 23, 2020
8afb5e2
minor state syntax updates
argyleink May 23, 2020
5e3c872
metatip style nudges
argyleink Jun 16, 2020
7775326
harden faux artboard name
argyleink Jun 16, 2020
d277811
zooming cursor update
argyleink Jun 16, 2020
ecba008
color values dont word break
argyleink Jun 16, 2020
84d6866
fixes linux, removed dupes, moved to switch
argyleink Jun 17, 2020
f4785cf
Merge branch 'main' of https://github.com/GoogleChromeLabs/ProjectVis…
argyleink Jun 17, 2020
7fcdbe1
fixes artboard name and shadow
argyleink Jun 17, 2020
50885eb
Merge branch 'artboard' of https://github.com/GoogleChromeLabs/Projec…
argyleink Jun 17, 2020
3511db0
macOS keyboard zooming works again
argyleink Jun 17, 2020
936af42
nits n fixes
argyleink Jun 17, 2020
b5a915e
fixes left quadrant measurement regression
argyleink Jun 17, 2020
bb950e5
Merge branch 'main' of https://github.com/GoogleChromeLabs/ProjectVis…
argyleink Jun 19, 2020
68f47e8
shifted more ownership to the module
argyleink Jun 17, 2020
bbfea56
Merge branch 'main' into artboard
argyleink Jun 26, 2020
7ecad42
prep for extension option
argyleink Dec 30, 2020
682d84a
Merge branch 'main' of github.com:GoogleChromeLabs/ProjectVisBug into…
argyleink Dec 30, 2020
720da24
view style controlled from extension setting
argyleink Dec 30, 2020
9d52460
extract demo code to isolated script
argyleink Dec 31, 2020
990e5f8
more natural zoom scaling
argyleink Dec 31, 2020
141f796
ensure visbug is prepended
argyleink Dec 31, 2020
cd650e0
Merge branch 'artboard' of https://github.com/GoogleChromeLabs/Projec…
argyleink Jan 7, 2021
1add3ef
Merge branch 'main' into artboard
argyleink Jan 7, 2021
8a20ee0
Merge branch 'main' into artboard
argyleink Jun 1, 2021
d76b6d2
restores metatip insertion location after merge with main
argyleink Jun 1, 2021
515be10
simplify and enhance the artboard canvas color logic
argyleink Jun 2, 2021
f829614
fixes head contents inside body oddity
argyleink Jun 2, 2021
2790e1c
more width to scroll and zoom
argyleink Jun 2, 2021
5b45f94
Merge branch 'main' into artboard
argyleink Jun 3, 2021
638f750
Merge branch 'main' into artboard
argyleink Jun 4, 2021
a704f92
Merge branch 'main' into artboard
argyleink Jun 4, 2021
f5da680
fixes merge issue
argyleink Jun 4, 2021
ed2ba54
toggle artboard effect by toggling constructed styles
argyleink Jun 10, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/components/selection/box-model.element.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class BoxModel extends HTMLElement {
height: bounds.height,
width: bounds.width,
top: bounds.top + window.scrollY,
left: bounds.left,
left: bounds.left + window.scrollX,
rotation: 'rotate(-45)',
}
}
Expand All @@ -38,7 +38,7 @@ export class BoxModel extends HTMLElement {
height: total_height,
width: total_width,
top: bounds.top + window.scrollY - sides.top,
left: bounds.left - sides.left,
left: bounds.left + window.scrollX - sides.left,
rotation: 'rotate(45)',
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/components/selection/distance.element.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export class Distance extends HTMLElement {

set styleProps({y,x,d,q,v = false, color}) {
this.style.setProperty('--top', `${y + window.scrollY}px`)
this.style.setProperty('--right', q === 'left' ? `${x}px` : 'auto')
this.style.setProperty('--left', q !== 'left' ? `${x}px` : 'auto')
this.style.setProperty('--right', q === 'left' ? `${x-window.scrollX}px` : 'auto')
this.style.setProperty('--left', q !== 'left' ? `${x+window.scrollX}px` : 'auto')
this.style.setProperty('--direction', v ? 'column' : 'row')
this.style.setProperty('--quadrant', q)

Expand Down
21 changes: 11 additions & 10 deletions app/components/selection/gridlines.element.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export class Gridlines extends HTMLElement {
const { winHeight, winWidth } = windowBounds()
const [svg] = this.$shadow.children
const [rect,line1,line2,line3,line4] = svg.children
top = top + window.scrollY
left = left + window.scrollX

this.$shadow.host.style.display = 'block'

Expand All @@ -33,18 +35,17 @@ export class Gridlines extends HTMLElement {
line1.setAttribute('x2', left)
line2.setAttribute('x1', left + width)
line2.setAttribute('x2', left + width)
line3.setAttribute('y1', top + window.scrollY)
line3.setAttribute('y2', top + window.scrollY)
line3.setAttribute('x2', winWidth)
line4.setAttribute('y1', top + window.scrollY + height)
line4.setAttribute('y2', top + window.scrollY + height)
line4.setAttribute('x2', winWidth)
line3.setAttribute('y1', top)
line3.setAttribute('y2', top)
line3.setAttribute('x2', left + winWidth)
line4.setAttribute('y1', top + height)
line4.setAttribute('y2', top + height)
line4.setAttribute('x2', left + winWidth)
}

render({ x, y, width, height, top, left }) {
const { winWidth, winHeight } = windowBounds()
const { offsetHeight } = document.body
const calced_y = y + window.scrollY
const { offsetHeight, offsetWidth } = document.body

return `
<svg
Expand All @@ -60,8 +61,8 @@ export class Gridlines extends HTMLElement {
></rect>
<line x1="${x}" y1="0" x2="${x}" y2="${offsetHeight}"></line>
<line x1="${x + width}" y1="0" x2="${x + width}" y2="${offsetHeight}"></line>
<line x1="0" y1="${calced_y}" x2="${winWidth}" y2="${calced_y}"></line>
<line x1="0" y1="${calced_y + height}" x2="${winWidth}" y2="${calced_y + height}"></line>
<line x1="0" y1="${y}" x2="${winWidth}" y2="${y}"></line>
<line x1="0" y1="${y + height}" x2="${winWidth}" y2="${y + height}"></line>
</svg>
`
}
Expand Down
4 changes: 2 additions & 2 deletions app/components/selection/handles.element.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export class Handles extends HTMLElement {
render({ x, y, width, height, top, left }, node_label_id, isFixed) {
this.$shadow.host.setAttribute('data-label-id', node_label_id)

this.style.setProperty('--top', `${top + (isFixed ? 0 : window.scrollY)}px`)
this.style.setProperty('--left', `${left}px`)
this.style.setProperty('--top', `${top+window.scrollY}px`)
this.style.setProperty('--left', `${left+window.scrollX}px`)
this.style.setProperty('--position', isFixed ? 'fixed' : 'absolute')

return `
Expand Down
4 changes: 2 additions & 2 deletions app/components/selection/hover.element.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export class Hover extends Handles {
}

render({ width, height, top, left }, node_label_id, isFixed) {
this.style.setProperty('--top', `${top + (isFixed ? 0 : window.scrollY)}px`)
this.style.setProperty('--left', `${left}px`)
this.style.setProperty('--top', `${top + window.scrollY}px`)
this.style.setProperty('--left', `${left + window.scrollX}px`)
this.style.setProperty('--position', isFixed ? 'fixed' : 'absolute')

return `
Expand Down
2 changes: 1 addition & 1 deletion app/components/selection/label.element.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class Label extends HTMLElement {

set update({boundingRect, isFixed}) {
this.style.setProperty('--top', `${boundingRect.y + (isFixed ? 0 : window.scrollY)}px`)
this.style.setProperty('--left', `${boundingRect.x - 1}px`)
this.style.setProperty('--left', `${boundingRect.x + window.scrollX - 1}px`)
this.style.setProperty('--max-width', `${boundingRect.width + (window.innerWidth - boundingRect.x - boundingRect.width - 20)}px`)
this.style.setProperty('--position', isFixed ? 'fixed' : 'absolute');
}
Expand Down
2 changes: 1 addition & 1 deletion app/components/selection/overlay.element.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class Overlay extends HTMLElement {
this.$shadow.host.style.display = 'block'
svg.style.display = 'block'

this.style.setProperty('--top', `${top + window.scrollY}px`)
this.style.setProperty('--top', `${top}px`)
this.style.setProperty('--left', `${left - 1}px`)

svg.setAttribute('width', width + 'px')
Expand Down
26 changes: 14 additions & 12 deletions app/components/styles.store.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import 'construct-style-sheets-polyfill'

import { default as visbug_css } from './vis-bug/vis-bug.element.css'
import { default as handle_css } from './selection/handles.element.css'
import { default as hover_css } from './selection/hover.element.css'
import { default as corners_css } from './selection/corners.element.css'
import { default as distance_css } from './selection/distance.element.css'
import { default as gridline_css } from './selection/gridlines.element.css'
import { default as label_css } from './selection/label.element.css'
import { default as overlay_css } from './selection/overlay.element.css'
import { default as boxmodel_css } from './selection/box-model.element.css'
import { default as metatip_css } from './metatip/metatip.element.css'
import { default as hotkeymap_css } from './hotkey-map/base.element.css'
import { default as grip_css } from './selection/grip.element.css'
import { default as visbug_css } from './vis-bug/vis-bug.element.css'
import { default as visbug_artboard_css } from './vis-bug/vis-bug.artboard.css'
import { default as handle_css } from './selection/handles.element.css'
import { default as hover_css } from './selection/hover.element.css'
import { default as corners_css } from './selection/corners.element.css'
import { default as distance_css } from './selection/distance.element.css'
import { default as gridline_css } from './selection/gridlines.element.css'
import { default as label_css } from './selection/label.element.css'
import { default as overlay_css } from './selection/overlay.element.css'
import { default as boxmodel_css } from './selection/box-model.element.css'
import { default as metatip_css } from './metatip/metatip.element.css'
import { default as hotkeymap_css } from './hotkey-map/base.element.css'
import { default as grip_css } from './selection/grip.element.css'

import { default as light_css } from './_variables_light.css'
import { default as visbug_light_css } from './vis-bug/vis-bug.element_light.css'
Expand All @@ -29,6 +30,7 @@ const constructStylesheet = (styles, stylesheet = new CSSStyleSheet()) => {
}

export const VisBugStyles = constructStylesheet(visbug_css)
export const ArtboardStyles = constructStylesheet(visbug_artboard_css)
export const HandleStyles = constructStylesheet(handle_css)
export const HoverStyles = constructStylesheet(hover_css)
export const CornerStyles = constructStylesheet(corners_css)
Expand Down
21 changes: 21 additions & 0 deletions app/components/vis-bug/vis-bug.artboard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
html {
display: grid;
grid: auto / 100vw;
place-content: center;
background-color: Canvas !important;
overflow: scroll !important;
}

body {
min-height: 100vh;
outline: 1px solid ButtonFace;
box-shadow: 0 2px 5px hsl(0 0% 0% / 25%) !important;
box-shadow:
0 3px 2px hsl(0 0% 0% / 2%),
0 7px 5px hsl(0 0% 0% / 2%),
0 13px 10px hsl(0 0% 0% / 3%),
0 22px 18px hsl(0 0% 0% / 4%),
0 42px 33px hsl(0 0% 0% / 5%),
0 100px 80px hsl(0 0% 0% / 7%) !important
;
}
4 changes: 0 additions & 4 deletions app/components/vis-bug/vis-bug.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
body {
min-height: 100vh;
}

body:not([testing]) [data-selected=true] {
transition: all 0.15s ease;
}
Expand Down
22 changes: 18 additions & 4 deletions app/components/vis-bug/vis-bug.element.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import {
Selectable, Moveable, Padding, Margin, EditText, Font,
Flex, Search, ColorPicker, BoxShadow, HueShift, MetaTip,
Guides, Screenshot, Position, Accessibility, draggable
Guides, Screenshot, Position, Accessibility, draggable, Zoom
} from '../../features/'

import {
Expand Down Expand Up @@ -55,6 +55,9 @@ export default class VisBug extends HTMLElement {

provideSelectorEngine(this.selectorEngine)

if (this.getAttribute('viewmode') == 'artboard')
Zoom.start(this.selectorEngine)

this.toolSelected($('[data-tool="guides"]', this.$shadow)[0])
}

Expand All @@ -65,10 +68,19 @@ export default class VisBug extends HTMLElement {
hotkeys.unbind(
Object.keys(this.toolbar_model).reduce((events, key) =>
events += ',' + key, ''))
hotkeys.unbind(`${metaKey}+/`)
hotkeys.unbind(`${metaKey}+/,${metaKey}+.`)

if (this.getAttribute('viewmode') == 'artboard')
Zoom.stop()
}

static get observedAttributes() { return ['viewmode','color-scheme'] }

attributeChangedCallback(name, oldValue, newValue) {
newValue === 'artboard'
? Zoom.start(this.selectorEngine)
: Zoom.stop()

if (name === 'color-scheme')
this.applyScheme(newValue)
}
Expand All @@ -80,6 +92,10 @@ export default class VisBug extends HTMLElement {
? this.getAttribute('color-mode')
: this.setAttribute('color-mode', 'hex')

this.hasAttribute('viewmode')
? this.getAttribute('viewmode')
: this.setAttribute('viewmode', 'document')

this.hasAttribute('color-scheme')
? this.getAttribute('color-scheme')
: this.setAttribute('color-scheme', 'auto')
Expand Down Expand Up @@ -114,8 +130,6 @@ export default class VisBug extends HTMLElement {
.filter(node => node.nodeName.includes('VISBUG'))
.forEach(el => el.remove())

this.teardown();

document.querySelectorAll('[data-pseudo-select=true]')
.forEach(el =>
el.removeAttribute('data-pseudo-select'))
Expand Down
15 changes: 15 additions & 0 deletions app/demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const metaKey = window.navigator.platform.includes('Mac')
? 'cmd'
: 'ctrl'

document.firstElementChild.prepend(document.querySelector('vis-bug'))

if ('ontouchstart' in document.documentElement)
document.getElementById('mobile-info').style.display = ''

if (metaKey === 'ctrl')
[...document.querySelectorAll('kbd')]
.forEach(node => {
node.textContent = node.textContent.replace('cmd','ctrl')
node.textContent = node.textContent.replace('opt','alt')
})
1 change: 0 additions & 1 deletion app/demo/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ html[light] {

body {
margin: 0;
padding-left: 4rem;
background: var(--dark-grey);
color: var(--lighter-grey);
font-family: system-ui;
Expand Down
2 changes: 1 addition & 1 deletion app/features/accessibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const mouseMove = e => {
export function showTip(target, e) {
if (!state.active.tip) { // create
const tip = render(target)
document.body.appendChild(tip)
document.body.insertAdjacentElement('afterend', tip)

positionTip(tip, e)
observe({tip, target})
Expand Down
6 changes: 3 additions & 3 deletions app/features/guides.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function createGuide(vert = true) {
z-index: 2147483643;
`

vert
vert
? styles += `
width: 1px;
height: 100vh;
Expand Down Expand Up @@ -97,11 +97,11 @@ const showGridlines = node => {
state.gridlines = document.createElement('visbug-gridlines')
state.gridlines.position = node.getBoundingClientRect()

document.body.appendChild(state.gridlines)
document.body.insertAdjacentElement('afterend', state.gridlines)
}
}

const hideGridlines = () => {
export const hideGridlines = () => {
if (!state.gridlines) return
state.gridlines.style.display = 'none'
}
2 changes: 1 addition & 1 deletion app/features/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ export { Guides } from './guides'
export { Screenshot } from './screenshot'
export { Position, draggable } from './position'
export { Accessibility } from './accessibility'

export { Zoom } from './zoom'
2 changes: 1 addition & 1 deletion app/features/measurements.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export function createMeasurements({$anchor, $target}) {
node_label_id: state.distances.length,
}

document.body.appendChild($measurement)
document.body.insertAdjacentElement('afterend', $measurement)
state.distances[state.distances.length] = $measurement
})
}
Expand Down
2 changes: 1 addition & 1 deletion app/features/metatip.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const mouseMove = e => {
export function showTip(target, e) {
if (!state.active.tip) { // create
const tip = render(target)
document.body.appendChild(tip)
document.body.insertAdjacentElement('afterend', tip)

positionTip(tip, e)
observe({tip, target})
Expand Down
14 changes: 9 additions & 5 deletions app/features/selectable.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ export function Selectable(visbug) {

did_hide = false
}

if (!e.metaKey) {
document.body.style.cursor = ''
}
}
}

Expand Down Expand Up @@ -602,7 +606,7 @@ export function Selectable(visbug) {
isFixed: isFixed(el),
}

document.body.appendChild(label)
document.body.insertAdjacentElement('afterend', label)

$(label).on('query', ({detail}) => {
if (!detail.text) return
Expand Down Expand Up @@ -635,7 +639,7 @@ export function Selectable(visbug) {

handle.position = { el, node_label_id: id }

document.body.appendChild(handle)
document.body.insertAdjacentElement('afterend', handle)

handles[handles.length] = handle
return handle
Expand All @@ -648,7 +652,7 @@ export function Selectable(visbug) {
hover_state.element.remove()

hover_state.element = document.createElement('visbug-hover')
document.body.appendChild(hover_state.element)
document.body.insertAdjacentElement('afterend',hover_state.element)
hover_state.element.position = {el}

return hover_state.element
Expand All @@ -661,7 +665,7 @@ export function Selectable(visbug) {
hover_state.label.remove()

hover_state.label = document.createElement('visbug-label')
document.body.appendChild(hover_state.label)
document.body.insertAdjacentElement('afterend', hover_state.label)

hover_state.label.text = text
hover_state.label.position = {
Expand All @@ -682,7 +686,7 @@ export function Selectable(visbug) {
hover_state.element.remove()

hover_state.element = document.createElement('visbug-corners')
document.body.appendChild(hover_state.element)
document.body.insertAdjacentElement('afterend', hover_state.element)
hover_state.element.position = {el}

return hover_state.element
Expand Down