forked from oku-ui/primitives
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(aspect-ratio): ts to sfc (oku-ui#497)
* refactor: visually-hidden ts to sfc * Refactor VisuallyHidden.vue component to use useComponentRef * refactor: aspect-ratio * refactor: export AspectRatioProps * refactor: add inheritAttrs option * fix: typo * chore: update snapshots
- Loading branch information
Showing
8 changed files
with
106 additions
and
121 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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<script lang="ts"> | ||
import type { PrimitiveProps } from '@oku-ui/primitive' | ||
export interface AspectRatioProps extends PrimitiveProps { | ||
ratio?: number | ||
} | ||
</script> | ||
|
||
<script setup lang="ts"> | ||
import { defineOptions } from 'vue' | ||
import { useComponentRef } from '@oku-ui/use-composable' | ||
import { Primitive } from '@oku-ui/primitive' | ||
defineOptions({ | ||
name: 'OkuAspectRatio', | ||
inheritAttrs: false, | ||
}) | ||
const props = withDefaults(defineProps<AspectRatioProps>(), { | ||
ratio: 1 / 1, | ||
}) | ||
const { componentRef } = useComponentRef<HTMLDivElement | null>() | ||
</script> | ||
|
||
<template> | ||
<div | ||
:style="{ | ||
// ensures inner element is contained | ||
position: 'relative', | ||
// ensures padding bottom trick maths works | ||
width: '100%', | ||
paddingBottom: `${100 / props.ratio}%`, | ||
}" | ||
data-oku-aspect-ratio-wrapper="" | ||
> | ||
<Primitive | ||
is="div" | ||
v-bind="$attrs" | ||
ref="componentRef" | ||
:style="{ | ||
...$attrs.style as any, | ||
// ensures children expand in ratio | ||
position: 'absolute', | ||
top: '0px', | ||
right: '0px', | ||
left: '0px', | ||
bottom: '0px', | ||
}" | ||
> | ||
<slot /> | ||
</Primitive> | ||
</div> | ||
</template> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
export { OkuAspectRatio } from './aspect-ratio' | ||
|
||
export type { | ||
AspectRatioProps, | ||
AspectRatioElement, | ||
AspectRatioNativeElement, | ||
} from './props' | ||
export { | ||
default as OkuAspectRatio, | ||
type AspectRatioProps, | ||
} from './AspectRatio.vue' |
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
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