casesandberg / casesandberg/reactcss
Proposal: Support for symbols
- Dominant language
- JavaScript
- Stars
- 1.6k
- Forks
- 74
- PR merge metrics
- No merged PRs in 30d
Description
Symbols offer nice features such as ensuring that enums values are actually distinct across different enums.
It would be nice to be able to supply symbols as modifiers so that multiple modifiers of different enums were supported.
Take this example.
```js
const MyEnum = {
A: 'A',
B: 'B',
C: 'C',
};
const YourEnum = {
A: 'A',
B: 'B',
C: 'C',
};
const styles = reactCSS({
default: {
root: {
width: 10,
}
},
[MyEnum.A]: {
root: {
width: 20,
}
},
[YourEnum.A]: {
root: {
height: 10,
}
}
}, {
[MyEnum.A]: x === MyEnum.A,
[YourEnum.A]: y === YourEnum.A,
});
```
This would cause a conflict in keys. To solve this problem enums are often written using symbols.
```js
const MyEnum = {
A: Symbol('A'),
B: Symbol('B'),
C: Symbol('C'),
};
const YourEnum = {
A: Symbol('A'),
B: Symbol('B'),
C: Symbol('C'),
};
```
The current for own, and to string of `key-value` doesn't permit symbols to be used.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the implementation of the current “for own” and “to string” handling referenced in the issue. Reproduce the example with symbol-based modifiers and verify that distinct symbols remain separate; done means modifiers from different enums no longer conflict.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100