Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: migrate location-provider component to vue 2.7 #1421

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: {
location: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add docs

type: String as PropType<FeatureLocation>,
required: true
}
},
setup(props, { slots }) {
const locationFeature = toRef(props, 'location');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think calling it just location works well here. Also, the name indicates something that is a feature about locations, not the location of a feature. The type is FeatureLocation so, if you want to keep the feature part, the name should be featureLocation.

/**
* The {@link FeatureLocation} to provide.
*
* @public
*/
provide('location', locationFeature);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need docs, the prop above does.


return () => useNoElementRender(slots);
}
});
</script>

<docs lang="mdx">
Expand Down
Loading