@usableapp/cardds 0.7.110 → 0.7.111
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/css/parts.css +4 -0
- package/dist/cardds.css +4 -0
- package/dist/catalog.json +1 -1
- package/lib/catalog.mjs +4 -4
- package/package.json +1 -1
package/lib/catalog.mjs
CHANGED
|
@@ -150,7 +150,7 @@ export function find(cat, query, axes = {}) {
|
|
|
150
150
|
// every three words of the request in a row, function words kept: a note that says "a or b" or "at a glance" as asked is the piece the request describes
|
|
151
151
|
const all = words(String(query));
|
|
152
152
|
const phrases = all.slice(2).map((w, i) => ` ${all[i]} ${all[i + 1]} ${w} `);
|
|
153
|
-
const rank = (items, fields, level, said = () => 0, saysIt = () => '') => { // a field is [text, weight, match = hits]; saysIt is the text whose phrases count
|
|
153
|
+
const rank = (items, fields, level, said = () => 0, saysIt = () => '', variant = () => 0) => { // a field is [text, weight, match = hits]; saysIt is the text whose phrases count
|
|
154
154
|
const scored = items.map((item) => {
|
|
155
155
|
let matched = 0, score = 0;
|
|
156
156
|
for (const t of toks) {
|
|
@@ -159,9 +159,9 @@ export function find(cat, query, axes = {}) {
|
|
|
159
159
|
}
|
|
160
160
|
const own = ` ${words(saysIt(item)).join(' ')} `;
|
|
161
161
|
score += 3 * phrases.filter((p) => own.includes(p)).length;
|
|
162
|
-
return { item, matched, score, level: active ? level(item) : 0, said: active ? said(item) : 0 };
|
|
162
|
+
return { item, matched, score, level: active ? level(item) : 0, said: active ? said(item) : 0, variant: variant(item) };
|
|
163
163
|
});
|
|
164
|
-
const byWords = (a, b) => b.matched - a.matched || b.score - a.score;
|
|
164
|
+
const byWords = (a, b) => b.matched - a.matched || b.score - a.score || a.variant - b.variant; // equal words: the picture that is another's again with one thing changed goes last
|
|
165
165
|
const byAxes = (a, b) => b.said - a.said || b.level - a.level; // among equal words: the screen that says the axes itself, then one component over several
|
|
166
166
|
return { axis: scored.filter((r) => r.level).sort((a, b) => byWords(a, b) || byAxes(a, b)), rest: scored.filter((r) => r.matched && !r.level).sort(byWords) };
|
|
167
167
|
};
|
|
@@ -174,7 +174,7 @@ export function find(cat, query, axes = {}) {
|
|
|
174
174
|
return !matchesUnion(parts, asked.want) ? 0 : parts.some((r) => matches(r, asked.want)) ? 2 : 1; // `none` is about the whole screen: one show-only part is not enough
|
|
175
175
|
};
|
|
176
176
|
const said = (s) => axisWords.filter((v) => hits(s.description, v)).length;
|
|
177
|
-
const [screenAxis, screenRest] = tier(rank(screens, (s) => [[s.id, 5], [s.description, 3], [s.uses.join(' '), 1]], level, said), TOP);
|
|
177
|
+
const [screenAxis, screenRest] = tier(rank(screens, (s) => [[s.id, 5], [s.description, 3], [s.uses.join(' '), 1]], level, said, undefined, (s) => Number(screens.some((o) => o !== s && s.id.startsWith(o.id)))), TOP);
|
|
178
178
|
// a component is found by its name (the name that IS the word counts as much again as one that contains it: "card" is Card before FeedCard, whatever
|
|
179
179
|
// their other words say), its description, its role's note (what it is FOR, in the words of a request: "a setting turned on or off"), the values of its role
|
|
180
180
|
// a word says ("choose" → pick, "number"), what it stands in for, then its prop names
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usableapp/cardds",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.111",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "card-first mobile design system, React-first: the components in src/ are thin wrappers over the CSS contract (css/*.css stays the only truth); gallery/ shows every story live (npm run dev), tests/ measures the geometry.",
|