clay
clay copied to clipboard
[Feature Request] Seed id hash with parent's id
Currently, element id needs to be globally unique. Copy&paste or refactoring reusable components into functions would be a bit of a pain since you'd need to parameterize all the ids.
What if the id only has to be unique among siblings?
Clay__Rehash
already exists but it is only used for debugger.
The fact that it exists mean that kind of id is useful.
CLAY_ID_AUTO
on the other hand, does not allow providing a string and counter which are needed to identify elements independent of orders.
e.g: In a list of items.
There are 2 ways of doing this:
-
Make
CLAY_ID
andCLAY_IDI
context-dependent. This might break some existing code.Floating attachment may be a bit harder but there are workarounds like saving the id into a variable first.
-
Alternatively, provide
CLAY_LOCAL_ID
andCLAY_LOCAL_IDI
which takes the parent id as seed. Alternate names:-
CLAY_CTX_ID[I]
: context dependent id -
CLAY_SCOPED_ID[I]
-
I can make PR for either of these.