Skip to content

Commit 9689e15

Browse files
authored
Merge pull request #564 from SolidOS/profileEditA11y
Work towards accessibility
2 parents 7b68429 + 77ed82a commit 9689e15

7 files changed

Lines changed: 368 additions & 2539 deletions

File tree

jest.config.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ export default {
1111
'^.+\\.[tj]sx?$': ['babel-jest', { configFile: './babel.config.mjs' }],
1212
},
1313
transformIgnorePatterns: ['/node_modules/(?!lit-html).+\\.js'],
14+
moduleNameMapper: {
15+
'^SolidLogic$': 'solid-logic',
16+
'^UI$': 'solid-ui',
17+
'^\\$rdf$': 'rdflib',
18+
'\\.css$': '<rootDir>/test/__mocks__/styleMock.js'
19+
},
1420
setupFilesAfterEnv: ['./test/helpers/setup.ts'],
1521
testMatch: ['**/?(*.)+(spec|test).[tj]s?(x)'],
1622
roots: ['<rootDir>/src', '<rootDir>/test'],

package-lock.json

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

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414
],
1515
"scripts": {
1616
"clean": "rm -rf dist src/versionInfo.ts",
17-
"build": "npm run clean && npm run build-version && npm run typecheck && npm run build-dist && npm run postbuild-js",
17+
"build": "npm run clean && npm run build-version && npm run typecheck && npm run build-dist && npm run build-js && npm run postbuild-js",
1818
"build-version": "bash timestamp.sh > src/versionInfo.ts && ./node_modules/.bin/eslint 'src/versionInfo.ts' --fix",
19-
"build-dist": "npm run build-js && npm run build-types",
20-
"build-js": "babel src --out-dir dist --extensions '.ts,.js' --source-maps",
21-
"build-types": "tsc --emitDeclarationOnly",
19+
"build-dist": "webpack --progress",
20+
"build-js": "babel src --out-dir dist --extensions '.ts,.js' && tsc --emitDeclarationOnly",
2221
"postbuild-js": "rm -f dist/versionInfo.d.ts dist/versionInfo.d.ts.map",
2322
"lint": "eslint",
2423
"lint-fix": "eslint --fix",
@@ -71,6 +70,7 @@
7170
"pane-registry": "^3.0.1",
7271
"profile-pane": "^3.1.2",
7372
"solid-namespace": "^0.5.4",
73+
"solid-ui": "^3.0.4",
7474
"source-pane": "^3.0.1"
7575
},
7676
"overrides": {
@@ -93,6 +93,7 @@
9393
"babel-loader": "^10.0.0",
9494
"babel-plugin-inline-import": "^3.0.0",
9595
"buffer": "^6.0.3",
96+
"copy-webpack-plugin": "^13.0.1",
9697
"css-loader": "^7.1.4",
9798
"eslint": "^9.39.3",
9899
"globals": "^17.3.0",
@@ -108,8 +109,8 @@
108109
"react": "^19.2.4",
109110
"react-dom": "^19.2.4",
110111
"solid-logic": "^4.0.3",
111-
"solid-ui": "^3.0.4",
112112
"style-loader": "^4.0.0",
113+
"terser-webpack-plugin": "^5.3.16",
113114
"ts-jest": "^29.4.6",
114115
"ts-loader": "^9.5.4",
115116
"typescript": "^5.9.3",

src/outline/manager.css

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/* Styles extracted from manager.js */
2+
3+
.obj {
4+
margin: 0.2em;
5+
border: none;
6+
padding: 0;
7+
vertical-align: top;
8+
}
9+
10+
.pred, .pred.internal {
11+
/* Add any specific styles for predicate TDs here */
12+
}
13+
14+
.iconTD {
15+
margin: 0.2em;
16+
border: none;
17+
padding: 0;
18+
vertical-align: top;
19+
width: 0px;
20+
}
21+
22+
.labelTD {
23+
width: 100%;
24+
}
25+
26+
.paneIconTray {
27+
display: flex;
28+
justify-content: flex-start;
29+
align-items: center;
30+
}
31+
32+
.paneShown {
33+
width: 24px;
34+
border-radius: 0.5em;
35+
border-top: solid #222 1px;
36+
border-left: solid #222 0.1em;
37+
border-bottom: solid #eee 0.1em;
38+
border-right: solid #eee 0.1em;
39+
margin-left: 1em;
40+
padding: 3px;
41+
background-color: #ffd;
42+
}
43+
44+
.paneHidden {
45+
width: 24px;
46+
border-radius: 0.5em;
47+
margin-left: 1em;
48+
padding: 3px;
49+
}
50+
51+
.header {
52+
display: flex;
53+
justify-content: flex-start;
54+
align-items: center;
55+
flex-wrap: wrap;
56+
}
57+
58+
.strongHeader {
59+
font-size: 150%;
60+
margin: 0 0.6em 0 0;
61+
padding: 0.1em 0.4em;
62+
}
63+
64+
.tableFullWidth {
65+
width: 100%;
66+
}
67+
68+
.placeholderTable {
69+
width: 100%;
70+
}
71+
72+
.tdFlex {
73+
margin: 0.2em;
74+
border: none;
75+
padding: 0;
76+
vertical-align: top;
77+
display: flex;
78+
justify-content: space-between;
79+
flex-direction: row;
80+
}

src/outline/manager.js

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Outline Mode Manager
44
*/
55
import * as paneRegistry from 'pane-registry'
6+
import './manager.css'
67
import * as $rdf from 'rdflib'
78
import * as UI from 'solid-ui'
89
import { authn, authSession, store } from 'solid-logic'
@@ -170,11 +171,12 @@ export default function (context) {
170171
statement
171172
) {
172173
const td = dom.createElement('td')
173-
td.setAttribute(
174-
'style',
175-
'margin: 0.2em; border: none; padding: 0; vertical-align: top;'
176-
)
174+
td.classList.add('obj')
177175
td.setAttribute('notSelectable', 'false')
176+
td.style.margin = '0.2em'
177+
td.style.border = 'none'
178+
td.style.padding = '0'
179+
td.style.verticalAlign = 'top'
178180
const theClass = 'obj'
179181

180182
// set about and put 'expand' icon
@@ -198,7 +200,6 @@ export default function (context) {
198200
).addEventListener('click', expandMouseDownListener)
199201
}
200202
td.setAttribute('class', theClass) // this is how you find an object
201-
// @@ TAKE CSS OUT OF STYLE SHEET
202203
if (kb.whether(obj, UI.ns.rdf('type'), UI.ns.link('Request'))) {
203204
td.className = 'undetermined'
204205
} // @@? why-timbl
@@ -249,10 +250,7 @@ export default function (context) {
249250
// if (kb.statementsMatching(predicate,rdf('type'), UI.ns.link('Request')).length) predicateTD.className='undetermined';
250251

251252
const labelTD = dom.createElement('TD')
252-
labelTD.setAttribute(
253-
'style',
254-
'margin: 0.2em; border: none; padding: 0; vertical-align: top;'
255-
)
253+
labelTD.classList.add('labelTD')
256254
labelTD.setAttribute('notSelectable', 'true')
257255
labelTD.appendChild(dom.createTextNode(lab))
258256
predicateTD.appendChild(labelTD)
@@ -345,7 +343,7 @@ export default function (context) {
345343
const me = authn.currentUser()
346344
if (!me) return []
347345
const div = dom.createElement('div')
348-
const [books, pods] = await Promise.all([getAddressBooks(), getPods()])
346+
const [pods] = await Promise.all([getPods()])
349347
return [
350348
{
351349
paneName: 'home',
@@ -368,7 +366,6 @@ export default function (context) {
368366
icon: UI.icons.iconBase + 'noun_492246.svg'
369367
}
370368
]
371-
.concat(books)
372369
.concat(pods)
373370

374371
async function getPods () {
@@ -808,7 +805,7 @@ export default function (context) {
808805
const table = d.parentNode
809806
const par = table.parentNode
810807
const placeholder = dom.createElement('table')
811-
placeholder.setAttribute('style', 'width: 100%;')
808+
placeholder.classList.add('placeholderTable')
812809
par.replaceChild(placeholder, table)
813810
table.removeChild(d)
814811
par.replaceChild(table, placeholder) // Attempt to
@@ -827,7 +824,7 @@ export default function (context) {
827824
if (!table) {
828825
// Create a new property table
829826
table = dom.createElement('table')
830-
table.setAttribute('style', 'width: 100%;')
827+
table.classList.add('tableFullWidth')
831828
expandedHeaderTR(subject, pane, options).then(tr1 => {
832829
table.appendChild(tr1)
833830

@@ -2365,7 +2362,7 @@ export default function (context) {
23652362
} else if (obj.termType === 'Collection') {
23662363
// obj.elements is an array of the elements in the collection
23672364
rep = dom.createElement('table')
2368-
rep.setAttribute('style', 'width: 100%;')
2365+
rep.classList.add('tableFullWidth')
23692366
rep.setAttribute('about', obj.toNT())
23702367
/* Not sure which looks best -- with or without. I think without
23712368
@@ -2377,10 +2374,7 @@ export default function (context) {
23772374
const elt = obj.elements[i]
23782375
const row = rep.appendChild(dom.createElement('tr'))
23792376
const numcell = row.appendChild(dom.createElement('td'))
2380-
numcell.setAttribute(
2381-
'style',
2382-
'margin: 0.2em; border: none; padding: 0; vertical-align: top;'
2383-
)
2377+
numcell.classList.add('obj')
23842378
numcell.setAttribute('notSelectable', 'false')
23852379
numcell.setAttribute('about', obj.toNT())
23862380
numcell.innerHTML = i + 1 + ')'

test/__mocks__/styleMock.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = {}

webpack.config.mjs

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
import path from 'path'
2+
import TerserPlugin from 'terser-webpack-plugin'
3+
import CopyPlugin from 'copy-webpack-plugin'
4+
5+
const common = {
6+
entry: './src/index.ts',
7+
resolve: {
8+
extensions: ['.ts', '.js', '.json'],
9+
fallback: {
10+
path: false,
11+
},
12+
},
13+
module: {
14+
rules: [
15+
{
16+
test: /\.ts$/,
17+
use: 'ts-loader',
18+
exclude: /node_modules/,
19+
},
20+
{
21+
test: /\.css$/,
22+
use: ['style-loader', 'css-loader'],
23+
},
24+
{
25+
test: /\.ttl$/i,
26+
type: 'asset/source'
27+
}
28+
],
29+
},
30+
externals: {
31+
fs: 'null',
32+
'node-fetch': 'fetch',
33+
'isomorphic-fetch': 'fetch',
34+
'text-encoding': 'TextEncoder',
35+
'@trust/webcrypto': 'crypto',
36+
rdflib: 'rdflib',
37+
$rdf: 'rdflib',
38+
'solid-logic': 'SolidLogic',
39+
SolidLogic: 'SolidLogic',
40+
'solid-ui': 'UI',
41+
UI: 'UI',
42+
},
43+
devtool: 'source-map',
44+
}
45+
46+
const normalConfig = {
47+
...common,
48+
mode: 'production',
49+
output: {
50+
path: path.resolve(process.cwd(), 'dist'),
51+
filename: 'solid-panes.js',
52+
library: {
53+
type: 'umd',
54+
name: 'SolidPanes',
55+
export: 'default',
56+
},
57+
globalObject: 'this',
58+
clean: true,
59+
},
60+
plugins: [
61+
...(common.plugins || []),
62+
new CopyPlugin({
63+
patterns: [
64+
{
65+
from: 'src/**/*.css',
66+
to: ({ context, absoluteFilename }) => {
67+
// Preserve folder structure under dist/
68+
const relPath = path.relative(path.resolve('src'), absoluteFilename)
69+
return path.resolve('dist', relPath)
70+
},
71+
},
72+
],
73+
}),
74+
],
75+
optimization: {
76+
minimize: false,
77+
}
78+
}
79+
80+
const minConfig = {
81+
...common,
82+
mode: 'production',
83+
output: {
84+
path: path.resolve(process.cwd(), 'dist'),
85+
filename: 'solid-panes.min.js',
86+
library: {
87+
type: 'umd',
88+
name: 'SolidPanes',
89+
export: 'default',
90+
},
91+
globalObject: 'this',
92+
clean: false,
93+
},
94+
plugins: [
95+
...(common.plugins || []),
96+
new CopyPlugin({
97+
patterns: [
98+
{
99+
from: 'src/**/*.css',
100+
to: ({ context, absoluteFilename }) => {
101+
// Preserve folder structure under dist/
102+
const relPath = path.relative(path.resolve('src'), absoluteFilename)
103+
return path.resolve('dist', relPath)
104+
},
105+
},
106+
],
107+
}),
108+
],
109+
optimization: {
110+
minimize: true,
111+
minimizer: [
112+
new TerserPlugin({
113+
terserOptions: {
114+
format: {
115+
comments: false,
116+
},
117+
},
118+
extractComments: false,
119+
})
120+
],
121+
}
122+
}
123+
124+
export default [normalConfig, minConfig]

0 commit comments

Comments
 (0)