Skip to content

Commit ef69498

Browse files
mtelgkampheho
andauthored
Styling additions (#46)
* cleanup * remove visuallyhidden list transformation * fix baact adding undefined values to elements * implement new design * fix Capitalization --------- Co-authored-by: Sven Kummetz <[email protected]>
1 parent 6b85f34 commit ef69498

File tree

17 files changed

+275
-225
lines changed

17 files changed

+275
-225
lines changed

baact/baact.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ function DOMparseNode<P>(element: string, properties: Partial<P>, children: Baac
4848
}
4949
return
5050
}
51+
if (typeof value === 'undefined') {
52+
return
53+
}
5154

5255
value = isHTML ? String(value) : value
5356

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "baat",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"description": "Bookmarklet for running axe-core tests directly in the Browser",
55
"main": "index.js",
66
"scripts": {

src/config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export const config = {
88
differenceMode: false,
99
developer: false,
1010
reporter: 'v2',
11-
showAdditionalInformation: false,
1211
impactMapping: {}
1312
},
1413
size: {
@@ -24,7 +23,6 @@ export const settingNames = {
2423
autorun: 'autorun',
2524
differenceMode: 'differenceMode',
2625
developer: 'developer',
27-
showAdditionalInformation: 'showAdditionalInformation',
2826
impactMapping: 'impactMapping',
2927
}
3028

src/elements/Accordion/Accordion.tsx

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { baact, createRef } from '../../../baact/baact'
55
import { css } from '../../util/taggedString'
66

77
const border = `${theme.sizing.absolute.tiny} solid ${theme.palette.gray}`
8+
const padding = `${theme.sizing.relative.smaller} ${theme.sizing.relative.small}`
89

910
const styles = css`
1011
#container {
@@ -13,27 +14,32 @@ const styles = css`
1314
#handle {
1415
position: relative;
1516
display: flex;
16-
align-items: baseline;
17+
align-items: center;
1718
box-sizing: border-box;
18-
padding: ${theme.sizing.relative.tiny};
19-
border: 2px solid transparent;
19+
padding: ${theme.sizing.relative.smaller};
20+
border: none;
2021
text-align: left;
2122
border-bottom: ${border};
2223
background-color: ${theme.palette.white};
2324
width: 100%;
2425
cursor: pointer;
25-
color: #333;
26-
font-size: ${theme.sizing.relative.normal};
26+
color: var(--text-color);
27+
background-color: var(--color, ${theme.palette.white});
28+
}
29+
::slotted([slot='heading']) {
30+
margin: 0;
31+
font-size: ${theme.sizing.relative.large};
2732
}
2833
#handle baat-icon {
34+
align-self: baseline;
2935
color: var(--text-color);
3036
}
3137
#handle:focus {
3238
border-left-color: ${theme.palette.primaryDark};
3339
outline: none;
3440
}
3541
.open #handle {
36-
border-bottom: ${border};
42+
border-bottom: none;
3743
}
3844
.open #caret {
3945
transform: rotate(90deg);
@@ -48,17 +54,14 @@ const styles = css`
4854
border-bottom: none;
4955
}
5056
#caret {
51-
margin: 0 ${theme.sizing.relative.tiny};
57+
margin: ${theme.sizing.relative.tiny};
58+
align-self: baseline;
5259
z-index: 1;
5360
}
54-
.flex {
55-
display: flex;
56-
}
5761
#content {
5862
display: none;
59-
padding: ${theme.sizing.relative.small};
60-
padding-left: ${theme.sizing.relative.larger};
61-
border-left-color: var(--border-color, ${theme.palette.gray});
63+
padding: ${padding};
64+
border-left-color: var(--color, ${theme.palette.white});
6265
border-left-width: ${theme.sizing.absolute.normal};
6366
border-left-style: solid;
6467
}
@@ -73,7 +76,7 @@ interface IAccordionAccessor {
7376
folded: boolean
7477
fixed: boolean
7578
nestedRoot?: boolean
76-
borderColor?: string
79+
color?: string
7780
textColor?: string
7881
onChange?: (folded: boolean) => void
7982
}
@@ -84,7 +87,7 @@ export class Accordion extends BaseHTMLElement<IAccordionAccessor> implements IA
8487
folded: boolean = true
8588
fixed: boolean = false
8689
nestedRoot?: boolean = false
87-
borderColor?: string
90+
color?: string
8891
textColor?: string
8992
private containerRef = createRef<HTMLDivElement>()
9093
private contentRef = createRef<HTMLDivElement>()
@@ -102,8 +105,8 @@ export class Accordion extends BaseHTMLElement<IAccordionAccessor> implements IA
102105
case 'nestedRoot':
103106
this.updateNestedRoot()
104107
break
105-
case 'borderColor':
106-
this.updateBorderColor()
108+
case 'color':
109+
this.updateColor()
107110
break
108111
case 'textColor':
109112
this.updateTextColor()
@@ -137,10 +140,10 @@ export class Accordion extends BaseHTMLElement<IAccordionAccessor> implements IA
137140
this.containerRef.value?.classList.toggle('nestedRoot', !!this.nestedRoot)
138141
}
139142

140-
updateBorderColor() {
143+
updateColor() {
141144
if (!this.shadowRoot) return;
142145

143-
this.containerRef.value?.style.setProperty('--border-color', this.borderColor ?? theme.palette.gray)
146+
this.containerRef.value?.style.setProperty('--color', this.color ?? theme.palette.white)
144147
}
145148

146149
updateTextColor() {
@@ -161,7 +164,7 @@ export class Accordion extends BaseHTMLElement<IAccordionAccessor> implements IA
161164
this.shadowRoot?.appendChild(
162165
<div id='container' ref={this.containerRef}>
163166
<button id='handle' onClick={handleMouseUp}>
164-
<div id='caret'><Icon width="16" height="16"><path stroke-width="5" stroke="currentColor" d="M 11,43 37,24 11,5"/></Icon></div>
167+
<div id='caret'><Icon width="16" height="16"><path stroke-width="5" stroke="currentColor" d="M12.213 45.213L33.426 24L12.213 2.787"/></Icon></div>
165168
<slot name='heading'></slot>
166169
</button>
167170
<div id='content' ref={this.contentRef}>
@@ -173,7 +176,7 @@ export class Accordion extends BaseHTMLElement<IAccordionAccessor> implements IA
173176
this.updateFixed()
174177
this.updateFolded()
175178
this.updateNestedRoot()
176-
this.updateBorderColor()
179+
this.updateColor()
177180
this.updateTextColor()
178181

179182
this.initialized = true

src/elements/Checkbox/Checkbox.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ const styles = css`
3535
3636
.container {
3737
position: relative;
38-
padding-top:.5rem;
39-
padding-left: 2rem;
38+
padding-top:.25rem;
39+
padding-left: 1.75rem;
4040
cursor: pointer;
4141
margin-bottom: ${theme.sizing.relative.tiny};
4242
}
@@ -46,15 +46,14 @@ const styles = css`
4646
left: 0;
4747
width: 1.25rem;
4848
height: 1.25rem;
49-
margin: .25rem;
5049
border: 1px solid #333;
50+
border-radius: 2px;
5151
color: transparent;
5252
}
5353
.container input[type="checkbox"] ~ .checkbox > i > svg {
5454
margin: .25rem;
5555
width: .75rem;
5656
height: .75rem;
57-
5857
}
5958
.container input[type="checkbox"]:checked ~ .checkbox {
6059
color: #fff;

src/elements/HiddenViolation/HiddenViolation.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import { css } from '../../util/taggedString'
44
import { theme } from '../../theme'
55
import { baact, createRef } from '../../../baact/baact'
66
import { NodeResult, Result } from '../../types'
7-
import { Icon } from '..'
8-
import {baatSymbol} from "../../core/BAAT";
9-
import {settingNames} from "../../config";
7+
import { Icon } from '../Icon/Icon'
8+
import { baatSymbol } from "../../core/BAAT";
9+
import { settingNames } from "../../config";
1010

1111
const borderBottom = `${theme.sizing.absolute.tiny} solid ${theme.palette.gray}`;
12+
const padding = `${theme.sizing.relative.tiny} ${theme.sizing.relative.smaller}`;
1213

1314
const styles = css`
1415
.container {
@@ -34,7 +35,7 @@ const styles = css`
3435
gap: ${theme.sizing.relative.tiny};
3536
background-color: ${theme.palette.white};
3637
border: none;
37-
padding: ${theme.sizing.relative.tiny} ${theme.sizing.relative.smaller};
38+
padding: ${padding};
3839
cursor: pointer;
3940
font-size: 1rem;
4041
margin: -${theme.sizing.relative.tiny};
@@ -49,12 +50,6 @@ interface IHiddenViolationAccessor {
4950
result?: Result
5051
}
5152

52-
function createNodeLink(index: number, result: NodeResult, alternativeText?: string): HTMLLIElement {
53-
return <li>
54-
<NodeResultLink number={index} result={result} alternativeText={alternativeText}/>
55-
</li> as unknown as HTMLLIElement;
56-
}
57-
5853
export class HiddenViolation extends BaseHTMLElement<IHiddenViolationAccessor> implements IHiddenViolationAccessor {
5954
public static tagName: string = 'baat-hidden-violation'
6055
result?: Result

src/elements/NodeResultLink/NodeResultLink.tsx

Lines changed: 12 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ import { css } from '../../util/taggedString'
33
import { baact, createRef } from '../../../baact/baact'
44
import { theme } from '../../theme'
55
import { NodeResult } from 'axe-core'
6-
import { isHidden, ownText, removeAllChildren } from '../../util/dom'
6+
import { removeAllChildren } from '../../util/dom'
77
import { baatSymbol } from '../../core/BAAT'
88
import { BAATEvent, HighlightElement, SettingsChanged } from '../../types'
9-
import { Icon } from '..'
10-
import {settingNames} from "../../config";
9+
import { Icon } from '../Icon/Icon'
10+
import { settingNames } from "../../config";
11+
import { getElementFromNodeResult, getNameFromNodeResult } from '../../util/axe';
12+
13+
const padding = `${theme.sizing.relative.tiny} ${theme.sizing.relative.smaller}`;
1114

1215
const styles = css`
1316
:host {
@@ -20,9 +23,10 @@ const styles = css`
2023
font-family: sans-serif;
2124
gap: ${theme.sizing.relative.tiny};
2225
background-color: ${theme.palette.white};
26+
color: ${theme.palette.black};
2327
border: 1px solid;
2428
border-radius: 2px;
25-
padding: ${theme.sizing.relative.tiny} ${theme.sizing.relative.smaller};
29+
padding: ${padding};
2630
cursor: pointer;
2731
max-width: 100%;
2832
overflow: hidden;
@@ -35,22 +39,6 @@ const styles = css`
3539
button:hover {
3640
background-color: ${theme.palette.grayLight};
3741
}
38-
39-
button:disabled {
40-
cursor: default;
41-
color: #333;
42-
border: none;
43-
padding-left: calc(6px + 12px + ${theme.sizing.relative.smaller});
44-
}
45-
46-
button:disabled:hover {
47-
background-color: #fff;
48-
}
49-
50-
#info {
51-
padding-left: ${theme.sizing.relative.huge};
52-
font-size: ${theme.semanticSizing.font.small};
53-
}
5442
`
5543

5644
interface INodeLinkAccessor {
@@ -64,7 +52,6 @@ export class NodeResultLink extends BaseHTMLElement<INodeLinkAccessor> implement
6452
styles = styles
6553
static tagName: string = 'baat-node-link'
6654
private buttonRef = createRef<HTMLButtonElement>()
67-
private infoRef = createRef<HTMLDivElement>()
6855
private element: HTMLElement | null = null;
6956

7057
attributeChangedCallback<T extends keyof INodeLinkAccessor>(name: T, oldValue: INodeLinkAccessor[T], newValue: INodeLinkAccessor[T]) {
@@ -80,33 +67,14 @@ export class NodeResultLink extends BaseHTMLElement<INodeLinkAccessor> implement
8067

8168
update() {
8269
if (!this.shadowRoot || !this.isConnected) return
83-
let name = ""
84-
this.element = this.result?.element ?? document.querySelector(this?.result?.target?.join(', ') ?? '') as HTMLElement | null
85-
let hasLink = this.element && !isHidden(this.element)
86-
const devMode = window[baatSymbol].getSetting(settingNames.developer)
70+
let name = getNameFromNodeResult(this.result, window[baatSymbol].getSetting(settingNames.developer));
71+
this.element = getElementFromNodeResult(this.result);
8772

8873
removeAllChildren(this.buttonRef.value)
8974

90-
if (devMode) {
91-
name = this.result?.target.join(', ') ?? this.element?.tagName.toLowerCase() ?? ''
92-
} else {
93-
name = this.element ? ownText(this.element).trim() : ""
94-
95-
if (name === "") name = this.element?.tagName.toLowerCase() ?? this.result?.target.join(', ') ?? ""
96-
}
75+
this.buttonRef.value.appendChild(<Icon width="16" height="16"><g fill="none" stroke="#000" stroke-linecap="round" stroke-width="4.65"><circle cx="24" cy="24" r="16.3"/><path d="m24 2.5v11"/><path d="m24 35v10.5"/><path d="m45.5 24h-10.5"/><path d="m13.5 24h-11"/></g></Icon>)
9776

98-
if (hasLink || devMode) {
99-
this.buttonRef.value.appendChild(<Icon width="16" height="16"><g fill="none" stroke="#000" stroke-linecap="round" stroke-width="4.65"><circle cx="24" cy="24" r="16.3"/><path d="m24 2.5v11"/><path d="m24 35v10.5"/><path d="m45.5 24h-10.5"/><path d="m13.5 24h-11"/></g></Icon>)
100-
this.buttonRef.value.removeAttribute('disabled')
101-
} else {
102-
this.buttonRef.value.setAttribute('disabled', 'true')
103-
console.log(this.buttonRef);
104-
}
10577
this.buttonRef.value.appendChild(document.createTextNode(name))
106-
107-
this.infoRef.value.innerText = window[baatSymbol].getSetting<boolean>(settingNames.showAdditionalInformation)
108-
? this.result?.failureSummary ?? ''
109-
: ''
11078
}
11179

11280
initialize() {
@@ -123,12 +91,11 @@ export class NodeResultLink extends BaseHTMLElement<INodeLinkAccessor> implement
12391
}
12492

12593
window[baatSymbol].addEventListener(BAATEvent.ChangeSettings, ((event: CustomEvent<SettingsChanged>) => {
126-
if (event.detail.name === settingNames.developer || event.detail.name === settingNames.showAdditionalInformation) this.update()
94+
if (event.detail.name === settingNames.developer) this.update()
12795
}) as EventListener)
12896

12997
this.shadowRoot?.appendChild(<div>
13098
<button id='nodeLink' type='button' onClick={handleClick} ref={this.buttonRef}></button>
131-
<div id='info' ref={this.infoRef}></div>
13299
</div>)
133100

134101
this.update()

0 commit comments

Comments
 (0)