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

Switch proposal #785

Merged
merged 38 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e7e84a3
chore: initialize switch explainer
gfellerph Jul 15, 2023
c59f4cd
Update switch explainer
gfellerph Jul 19, 2023
f7b3ac7
Update switch.explainer.mdx
gfellerph Jul 24, 2023
1e5e423
Update non-goals
gfellerph Jul 24, 2023
b4f8321
Update switch.explainer.mdx
gfellerph Jul 25, 2023
3b64060
added anatomy images and updated formatting
gfellerph Jul 28, 2023
2a02b85
fix: improve question rendering
gfellerph Jul 28, 2023
fa2ec2f
Merge branch 'openui:main' into switch-proposal
gfellerph Jul 28, 2023
41794e7
Update switch.explainer.mdx
gfellerph Jul 28, 2023
b65b673
Incorporate feedback from @scottaohara about accessibility
gfellerph Aug 1, 2023
581a9f2
Added link to parallel efforts
gfellerph Aug 1, 2023
312efb4
Update accessibility section
gfellerph Aug 4, 2023
1fbf0cb
Updated DOM structure proposal to match elements approach
gfellerph Aug 4, 2023
bb3c0c3
Update research format for immediate action research
gfellerph Aug 4, 2023
75baa9a
Added link to research page
gfellerph Aug 4, 2023
e9379c6
Update DOM structure to reuse trackside element
gfellerph Aug 4, 2023
b8d57b2
fix image urls
gfellerph Aug 19, 2023
3446134
add screen recordings of prior art
gfellerph Aug 19, 2023
413b5d4
comment instructions
gfellerph Aug 19, 2023
d9004d3
update anatomy and parts section
gfellerph Aug 19, 2023
d30f0a9
Merge remote-tracking branch 'upstream/main' into switch-proposal
gfellerph Aug 19, 2023
33abbad
clarified sample size for analysis
gfellerph Aug 19, 2023
135a422
the antonym of toggled is untoggled
gfellerph Aug 19, 2023
bfd5f6f
added backlink to issue for reference
gfellerph Aug 19, 2023
e1f0e22
typo
gfellerph Aug 19, 2023
babfd08
Merge branch 'main' into switch-proposal
gfellerph Nov 15, 2023
5710d87
updated the explainer
gfellerph Nov 16, 2023
8a6c136
Update site/src/pages/components/switch.explainer.mdx
gfellerph Nov 17, 2023
cb8b459
Update site/src/pages/components/switch.explainer.mdx
gfellerph Nov 17, 2023
a7b6810
Update site/src/pages/components/switch.explainer.mdx
gfellerph Nov 17, 2023
2185e48
save hotlinked images locally and add attributions
gfellerph Nov 24, 2023
b433da9
remove the proposal for type="submit"
gfellerph Nov 24, 2023
031675d
clarify text
gfellerph Nov 24, 2023
1bcbf0b
specify interaction patterns
gfellerph Nov 24, 2023
0b5462a
clarify checked state
gfellerph Nov 24, 2023
04b8b47
added allowed content resolution
gfellerph Feb 12, 2024
c9095fb
add info about safari implementation of input switch
gfellerph Feb 12, 2024
b92a94a
update from comments on the PR
gfellerph Feb 12, 2024
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 7 additions & 5 deletions site/src/components/component-name-matrix.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,19 @@ const ComponentNameMatrix = (props) => {
const matchNameToCount = Object.entries(
matchNames.reduce((acc, value) => {
if (!acc[value]) {
acc[value] = 1;
acc[value] = 1
} else {
acc[value]++;
acc[value]++
}

return acc;
}, {})
return acc
}, {}),
).sort(([matchNameA, countA], [matchNameB, countB]) => {
return sort === SORT_OPTIONS.COMPONENT_NAME
? matchNameA.localeCompare(matchNameB)
: (SORT_OPTIONS.MATCH_COUNT ? countB - countA : matchNameA.localeCompare(matchNameB));
: SORT_OPTIONS.MATCH_COUNT
? countB - countA
: matchNameA.localeCompare(matchNameB)
})

return (
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/concept-coverage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import './concept-coverage.css'

const ConceptCoverage = ({ component, conceptName, openUIConceptName }) => {
const withConcept = getSourcesWithComponentConcept(component, conceptName, openUIConceptName)
const withoutConcept = sourceNames.filter(x => !withConcept.includes(x))
const withoutConcept = sourceNames.filter((x) => !withConcept.includes(x))

return (
<div className="concept-coverage">
Expand Down
574 changes: 574 additions & 0 deletions site/src/pages/components/switch.explainer.mdx

Large diffs are not rendered by default.

57 changes: 32 additions & 25 deletions site/src/sources/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,21 @@ export const sources = [
componentName: componentOpenUIName,
openUIName: conceptOpenUIName,
}
})
}),
}
}),
}))

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/groupBy
export const groupBy = (items, callbackFn) => {
return items.reduce((acc, currentValue, currentIndex) => {
let groupKey = callbackFn(currentValue, currentIndex);
let groupKey = callbackFn(currentValue, currentIndex)
if (!acc[groupKey]) {
acc[groupKey] = [];
acc[groupKey] = []
}
acc[groupKey].push(currentValue);
return acc;
}, {});
acc[groupKey].push(currentValue)
return acc
}, {})
}

export const get = (obj, path, defValue) => {
Expand All @@ -91,23 +91,18 @@ export const get = (obj, path, defValue) => {
// Regex explained: https://regexr.com/58j0k
const pathArray = Array.isArray(path) ? path : path.match(/([^[.\]])+/g)
// Find value
const result = pathArray.reduce(
(prevObj, key) => prevObj && prevObj[key],
obj
)
const result = pathArray.reduce((prevObj, key) => prevObj && prevObj[key], obj)
// If found value is undefined return default value; otherwise return the value
return result === undefined ? defValue : result
}

export const uniqBy = (arr, iteratee) => {
if (typeof iteratee === 'string') {
const prop = iteratee
iteratee = item => item[prop]
iteratee = (item) => item[prop]
}

return arr.filter(
(x, i, self) => i === self.findIndex(y => iteratee(x) === iteratee(y))
)
return arr.filter((x, i, self) => i === self.findIndex((y) => iteratee(x) === iteratee(y)))
}

export const sourceNames = sources.map((source) => source.name)
Expand All @@ -120,28 +115,40 @@ export const componentsByName = groupBy(componentList, (component) => component.

// Anatomies
export const anatomiesByComponent = Object.fromEntries(
Object.entries(componentsByName).map(([key, value]) =>
[key, uniqBy(value.flatMap((component) => component.anatomy).filter(Boolean), "name")])
Object.entries(componentsByName).map(([key, value]) => [
key,
uniqBy(value.flatMap((component) => component.anatomy).filter(Boolean), 'name'),
]),
)

// Concepts
const conceptList = componentList.flatMap((component) => component.concepts).filter(Boolean)

export const openUIConceptsByComponent = Object.fromEntries(Object.entries(groupBy(conceptList, concept => concept.componentName)).map(([key, value]) => [key, groupBy(value, concept => concept.openUIName)]))
export const openUIConceptsByComponent = Object.fromEntries(
Object.entries(groupBy(conceptList, (concept) => concept.componentName)).map(([key, value]) => [
key,
groupBy(value, (concept) => concept.openUIName),
]),
)

export const conceptsByComponent = Object.fromEntries(Object.entries(groupBy(conceptList, concept => concept.componentName)).map(([key, value]) => [key, groupBy(value, concept => concept.name)]))
export const conceptsByComponent = Object.fromEntries(
Object.entries(groupBy(conceptList, (concept) => concept.componentName)).map(([key, value]) => [
key,
groupBy(value, (concept) => concept.name),
]),
)

export const getSourcesWithComponentConcept = (
componentName,
conceptName,
conceptOpenUIName = conceptName,
) =>
[...new Set(
get(conceptsByComponent, [componentName, conceptName]).filter(
(concept) => concept.name === conceptName && concept.openUIName === conceptOpenUIName,
)
.map((concept) => concept.sourceName),
)]
) => [
...new Set(
get(conceptsByComponent, [componentName, conceptName])
.filter((concept) => concept.name === conceptName && concept.openUIName === conceptOpenUIName)
.map((concept) => concept.sourceName),
),
]

// Images
export const getImagesForComponentConcept = (componentOpenUIName, conceptOpenUIName) =>
Expand Down
24 changes: 22 additions & 2 deletions site/src/styles/spec.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
dl {
border: 1px solid rgba(0, 0, 0, 0.2);
padding: 1em;
margin-bottom: 1.125rem;
}

dd {
Expand All @@ -15,16 +16,35 @@ dd + dt {
background: #f7f781;
position: relative;
display: flex;
padding: 0.5em;
margin-bottom: 1.125rem;
counter-increment: questions;
}

.question p:last-child {
margin-bottom: 0;
}

.question::before {
background: #ffdf3f;
content: 'QUESTION ' counter(questions);
width: max-content;
padding: 0 0.5em;
margin-right: 0.5em;
margin: -0.5em 0.5em -0.5em -0.5em;
padding: 0.5em;
font-weight: bold;
flex-shrink: 0;
}

@media (max-width: 640px) {
.question {
flex-direction: column;
}

.question::before {
width: auto;
margin-right: -0.5em;
margin-bottom: 0.5rem;
}
}

.note {
Expand Down