Comments (6)
I like @patrickarlt's idea of a custom decorator.. I think the vast majority of "simple" prop validations will just be along the lines of...
@Prop({ reflect: true }) color: string = 'blue';
@Prop({ reflect: true }) theme: string = null;
...
componentWillLoad() {
let colors = ['blue', 'red', 'green', 'yellow']
if (!colors.includes(this.color)) this.color = 'blue';
let themes = ['dark', 'light']
if (this.theme !== null && !themes.includes(this.theme)) this.theme = 'light';
}
so to me an ideal solution that could cover most "initial load validations" would be ...
@ValidateProp({ reflect: true }) color: 'blue' | 'red' | 'yellow' | 'green' = 'blue';
@ValidateProp({ reflect: true }) theme: 'dark' | 'light' = null;
and then you could use the existing "@ Watch" for anything more complex or "on change" validations
from calcite-design-system.
Slots would be super tough to validate in any consistent manner IMO... But props should be, within reason.
For instance, validating that color
is one of "red, green, blue, yellow" or theme
is one of "dark, light" seems doable.
from calcite-design-system.
One possible way I can think of validating this.el.children
and validate how many and which element it is. But I am not sure how much trustworthy or how efficient it is.
from calcite-design-system.
What's the status of this issue? can we close this one?
from calcite-design-system.
Checking back in on this one.
from calcite-design-system.
Closing this due to inactivity, feel free to open another if something specific is needed.
from calcite-design-system.
Related Issues (20)
- input-date-picker: selecting day activates previous day in certain cases HOT 1
- Build storybook interfaces using component's class
- Add `clearable` behavior to date and time picker inputs
- [Block Section] When `toggle-display` is set to `"switch"` unable to toggle HOT 1
- bug(calcite-flow): visual stuttering if reduce-motion is on
- External content included in dragged list item (Safari only) HOT 3
- Initialization regression in `components` output target HOT 2
- [Carousel] Carousel Items shouldn't animate when using `Home` / `End` and destination Carousel Item is currently active
- Ensure all E2E tests pass in Chromium's `headless="new"` mode
- Table: update test code that uses the internals of the pagination component
- `setFocus` method not working on `input-date-picker` and `input-time-picker`
- bug: Preact typing doesn't work if using non-legacy TypeScript moduleResolution HOT 1
- [Accordion] Refactor register event
- [Alert] Refactor register event
- Popover is closed when created and opened dynamically (`components` output target) HOT 1
- bug: Missing @types/sortablejs dependency
- Popover should only get closed when clicking outside if the click was not initiated inside
- Expand openClose commonTest util to account for components with `closed/collapsed` props
- Revisit event names emitted by openCloseComponent util
- Consolidate interfaces imports HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from calcite-design-system.