Allow column options to be defined per column instead of globally
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 42/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript
- Ambito
- frontend
Direzione di ricerca
Start at the Table input implementation and inspect how the columns, width, format, and align options are currently handled. Update the option handling to support per-column objects while preserving array columns and global-option precedence, then verify the behavior against the examples and suggested rules in this issue.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The Table input presently supports four column related options:
columns, indicating which columns should be displayed, and in which orderwidth, defining either a global width or per-column widths (in object form)format, per-column formatters in object formalign, per-column text alignment in object form
It is reasonable to expect that more options will be added in the future, requiring column definitions to be spread across multiple global options.
Suggested solution
Support per-column options objects. The example below has been taken from this notebook and expands the columns option definitions via a custom helper function.
Example:
const time = {
width: relTime ? '8em' : '15em',
format: v => {
const d = new Date(v).toLocaleString('en-US');
return html`<span title="${relTime ? d : timeAgo(v)}">${relTime ? timeAgo(v) : d}`;
}
};
const columns = {
'title': {
format: (v, i, {[i]: d}) => html`<img height="25" style="display:inline-block;vertical-align:middle;margin-right:.5em" src="https://static.observableusercontent.com/thumbnail/${d.thumbnail}.jpg"><a href="/@${d.owner.login}/${d.slug}" style="font-weight:bold">${DOM.text(v)}`,
},
'update_time': time,
'publish_time': time,
'likes': {width: '3em', format: v => v || ''},
'comment_count': {width: '6em', format: v => v || ''},
'version': {width: '4em', format: v => v},
'fork_of': {width: '3em', format: v => v ? '✔' : '', align: 'center'},
};
Suggested Implementation
- For the Table option
columns, assume an object of per-column options indexed by column names, where the order of property keys defines the column order (as shown in the example above). - If
columnsis defined as an array, expand each item into an empty options object, as defined in 1. - If specified, merge the global options
width,format, andaligninto the existing options objects, taking precedence over already defined values.
- Lingua principale
- JavaScript
- Stelle
- 173
- Fork
- 40
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di observablehq/inputs
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
observablehq/inputs#133 · 1 reazione ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 42/100
observablehq/inputs#278 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
observablehq/inputs#277 · 2 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
observablehq/inputs#275 · 2 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
observablehq/inputs#273 · 2 commenti ·
Tutte le issue di observablehq/inputs
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
Graphify-Labs/graphify#4860 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
CommandCodeAI/command-code#1088 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
CanadaHonk/porffor#426 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
RIT-Software-Engineering/RIT-SE-Senior-Project#546 ·
I maintainer di solito rispondono entro 1 giorno