Skip to content

Commit

Permalink
refactor(components): migrate location-provider component to vue 2.7 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lauramargar authored Feb 23, 2024
1 parent fe464ee commit 98377e8
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions packages/x-components/src/components/location-provider.vue
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
<script lang="ts">
import { Prop, Provide, Component } from 'vue-property-decorator';
import { NoElement } from '../components/no-element';
import { defineComponent, PropType, provide, toRef } from 'vue';
import { FeatureLocation } from '../types';
import { useNoElementRender } from '../composables/index';
/**
* Location Provider component.
* This component injects the location with value passed as prop.
*
* @public
*/
@Component
export default class LocationProvider extends NoElement {
/**
* The {@link FeatureLocation} to provide.
*
* @public
*/
@Prop({ required: true })
@Provide()
protected location!: FeatureLocation;
}
export default defineComponent({
name: 'LocationProvider',
props: {
/**
* The {@link FeatureLocation} to provide.
*
* @public
*/
location: {
type: String as PropType<FeatureLocation>,
required: true
}
},
setup(props, { slots }) {
const featureLocation = toRef(props, 'location');
provide('location', featureLocation);
return () => useNoElementRender(slots);
}
});
</script>

<docs lang="mdx">
Expand Down

0 comments on commit 98377e8

Please sign in to comment.