-
Notifications
You must be signed in to change notification settings - Fork 0
InNumbers component interface #112
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
base: main
Are you sure you want to change the base?
Conversation
```ts | ||
interface InNumbersNumber extends Node { | ||
type: "in-numbers-number" | ||
numberLabel: string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
numberLabel: string | |
number: string |
Should we keep the field name consistent with BigNumber
?
(Incidentally I was wondering if it should be a number
rather than string
, but looks like BigNumber is also a string
!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea of using numberLabel is because I was leaving number
available in case one day we will have a proper number: number
, similarly to here we may have a date: Date
.
If we want to communicate consistency/relations perhaps we should do this:
interface Number extends Node {
number: string; << Still this is confusing to me
description: string;
}
interface BigNumber extends Number {
type: "big-number";
}
interface InNumbers extends Parent {
type: "in-numbers"
children: [Heading, Number, Number?, Number?]
}
but I wonder if this become a slippery slope towards some kind of coupling hell
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adgad On second thought, the likelihood to need a number as number seems very low, so we can go with your suggestion and same perhaps for the date
in the Timeline PR. At then end, as UI representation, the need of have better types it's small. In the long term though we may have issue to automatically associate for instance a datePicker in Spark to a field that is a string instead of a proper date, that kind of problems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I guess because we haven't had any validation till now in the CMS, it's very likely that we have existing timeline dates that aren't dates, big numbers that aren't numbers etc.
In the long term though we may have issue to automatically associate for instance a datePicker in Spark to a field that is a string instead of a proper date, that kind of problems.
yeah i can see this being useful with schema-generated components in the future, and being able to have validation in the CMS as well!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's very likely that we have existing timeline dates that aren't dates, big numbers that aren't numbers
Yep. The options are:
- Use the label
number
as a string in the new In Numbers component and usedate
as a string in the new Timeline component
- Pros: consistency with existing components
- Cons: It's confusing and it will prevent us one day to have proper
number
asnumber
anddate
asDate
and we may end-up in even more confusing choices likenumberAsNumber: number
- Use
label
for fields that are free string, Editorial can really put whatever they want there
- Pros: avoid future breaking change or increase of what seems unideal/confusing naming convention
- Cons: lost in consistency with existing nodes
IMO and this is also for @elpopova and @todor-videv1 perhaps, part of this topic is about which future do we see for the Content Tree as a document? Is it just for a UI with a bunch of strings or shall it evolve to something that machine should better understand too. I'm raising it because this is in some form related too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would keeping it to a generic thing like value
help for future modelling for simple types (as opposed to data structures)? e.g. Number.value, SimpleThing.value. Or a bit more specific like text
for strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @debugwand. I think this is a very good suggestion. It's already applied for Text here.
Potentially, we could use value
and not having a breaking change even if we move towards what I mentioned here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually, we could have something like...
interface Number extends Node {
value: number;
number: string;
description: string;
}
interface BigNumber extends Node {
type: "big-number";
} && Pick<Number, 'number', 'description' >
interface InNumbersNumber extends Node {
type: "in-numbers-number";
} && Pick<Number, 'value', 'description' >
interface InNumbers extends Parent {
type: "in-numbers"
children: [Heading, Number, Number?, Number?]
}
... but we may not get any particular value to tight to a single Number
node at this stage, perhaps we can keep them separated as they are in this PR and use value
that will still permit us in the future to merge the types without a breaking change if we desire to do so
} | ||
interface InNumbers extends Parent { | ||
type: "in-numbers"; | ||
children: [Heading, InNumbersNumber, InNumbersNumber?, InNumbersNumber?]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heading it's not mandatory and we need to support ImageSet
children: [Heading, InNumbersNumber, InNumbersNumber?, InNumbersNumber?]; | |
children: [Heading?, ImageSet?, InNumbersNumber, InNumbersNumber?, InNumbersNumber?]; |
/** Configuration data to be passed to the component. */ | ||
attributes: CustomCodeComponentAttributes; | ||
} | ||
interface InNumbersNumber extends Node { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We agreed with @adgad to use BigNumber instead of this (FE may need to be reviewed because styles used by big number)
Representation for an
In numbers
componentThis is related to the issue about moving away from the Layout component