reactcss
reactcss copied to clipboard
Proposal: Support for symbols
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.
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.
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.