29 lines
861 B
JavaScript
29 lines
861 B
JavaScript
// Utilities
|
|
import { computed, isRef } from 'vue';
|
|
import { propsFactory } from "../util/index.mjs"; // Types
|
|
// Composables
|
|
export const makeElevationProps = propsFactory({
|
|
elevation: {
|
|
type: [Number, String],
|
|
validator(v) {
|
|
const value = parseInt(v);
|
|
return !isNaN(value) && value >= 0 &&
|
|
// Material Design has a maximum elevation of 24
|
|
// https://material.io/design/environment/elevation.html#default-elevations
|
|
value <= 24;
|
|
}
|
|
}
|
|
}, 'elevation');
|
|
export function useElevation(props) {
|
|
const elevationClasses = computed(() => {
|
|
const elevation = isRef(props) ? props.value : props.elevation;
|
|
const classes = [];
|
|
if (elevation == null) return classes;
|
|
classes.push(`elevation-${elevation}`);
|
|
return classes;
|
|
});
|
|
return {
|
|
elevationClasses
|
|
};
|
|
}
|
|
//# sourceMappingURL=elevation.mjs.map
|