-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into EMP-4087-empathize-composition-api
- Loading branch information
Showing
12 changed files
with
200 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,15 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
## [1.0.0-alpha.13](https://github.com/empathyco/x/compare/[email protected]@1.0.0-alpha.13) (2024-05-27) | ||
|
||
|
||
### Features | ||
|
||
* Replace `layoutsmixin` by `useLayouts` composable (#1480) ([71feaae](https://github.com/empathyco/x/commit/71feaae8493fb683919967bdf52de161a4e4fbf2)) | ||
|
||
|
||
|
||
## [1.0.0-alpha.12](https://github.com/empathyco/x/compare/[email protected]@1.0.0-alpha.12) (2024-05-23) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/_vue3-migration-test/src/components/test-use-layouts.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<template> | ||
<button @click="devMode = !devMode">{{ devMode ? 'Hide slots' : 'Show slots' }}</button> | ||
<header v-if="hasContent('header')"> | ||
<!-- @slot Slot that is used to insert content into the Header. --> | ||
<slot name="header"> | ||
<span v-if="devMode">HEADER</span> | ||
</slot> | ||
</header> | ||
|
||
<div v-if="hasContent('sub-header')"> | ||
<!-- @slot Slot that can be used to insert content into the Sub Header. --> | ||
<slot name="sub-header"> | ||
<span v-if="devMode">SUB HEADER</span> | ||
</slot> | ||
</div> | ||
|
||
<main v-if="hasContent('main')" class="x-layout__main"> | ||
<!-- @slot Slot that can be used to insert content into the Main. --> | ||
<slot name="main"> | ||
<span v-if="devMode">MAIN</span> | ||
</slot> | ||
</main> | ||
</template> | ||
|
||
<script setup> | ||
import { useSlots, ref } from 'vue'; | ||
import { useLayouts } from '../../../x-components/src/components/layouts/use-layouts'; | ||
const slots = useSlots(); | ||
const devMode = ref(true); | ||
const { hasContent } = useLayouts(devMode.value, slots); | ||
</script> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,15 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
## [5.0.0-alpha.19](https://github.com/empathyco/x/compare/@empathyco/[email protected]...@empathyco/[email protected]) (2024-05-27) | ||
|
||
|
||
### Features | ||
|
||
* Replace `layoutsmixin` by `useLayouts` composable (#1480) ([71feaae](https://github.com/empathyco/x/commit/71feaae8493fb683919967bdf52de161a4e4fbf2)) | ||
|
||
|
||
|
||
## [5.0.0-alpha.18](https://github.com/empathyco/x/compare/@empathyco/[email protected]...@empathyco/[email protected]) (2024-05-23) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 0 additions & 37 deletions
37
packages/x-components/src/components/layouts/layouts.mixin.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/x-components/src/components/layouts/use-layouts.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { VNode } from 'vue'; | ||
import { Slots } from 'vue/types/v3-setup-context'; | ||
/** | ||
* Composable to share Layout logic. | ||
* | ||
* @param devMode - Shows the available slots to use with its names if it is enabled. | ||
* @param slots - Slots to show. | ||
* | ||
* @returns True if the slot has rendered content or false otherwise. | ||
* @public | ||
*/ | ||
export function useLayouts(devMode: boolean, slots: Slots) { | ||
/** | ||
* Function to check if an slot has rendered content or not. | ||
* | ||
* @param slotNames - A VNode Array with of each slot. | ||
* @returns True if the slot has rendered content or false otherwise. | ||
* | ||
* @internal | ||
*/ | ||
const hasContent = (...slotNames: string[]): boolean => { | ||
return ( | ||
(devMode || | ||
slotNames.some(slotName => | ||
slots[slotName]?.(undefined)?.some((vNode: VNode) => vNode.tag !== undefined) | ||
)) ?? | ||
false | ||
); | ||
}; | ||
|
||
return { hasContent }; | ||
} |