-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: cv tile components & story working
- Loading branch information
1 parent
18c9396
commit 926341e
Showing
29 changed files
with
323 additions
and
191 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-12.7 MB
.yarn/cache/@carbon-web-components-npm-1.25.0-7d91ffa8fa-f37b0d49af.zip
Binary file not shown.
Binary file removed
BIN
-3.99 MB
.yarn/cache/carbon-components-npm-10.58.3-57a9dc3544-84a7e6ad39.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,23 @@ | ||
<template> | ||
<bx-clickable-tile | ||
:color-scheme="light ? 'light' : undefined" | ||
:disabled="disabled ? 'disabled' : undefined" | ||
><slot>Clickable tile</slot></bx-clickable-tile | ||
<component | ||
:is="tagType" | ||
ref="target" | ||
data-tile="clickable" | ||
:class="`cv-tile-clickable ${carbonPrefix}--tile--clickable`" | ||
v-bind="{ ...$attrs, ...linkProps }" | ||
tabindex="0" | ||
> | ||
<slot></slot> | ||
</component> | ||
</template> | ||
|
||
<script setup> | ||
import '@carbon/web-components/es/components/tile/index.js'; | ||
defineProps({ | ||
light: { type: Boolean, default: false }, | ||
disabled: { type: Boolean, default: false }, | ||
import { carbonPrefix } from '../../global/settings'; | ||
import { props as propsLink, useLinkProps, useTagType } from '../../use/cvLink'; | ||
const props = defineProps({ | ||
...propsLink, | ||
}); | ||
const tagType = useTagType(props); | ||
const linkProps = useLinkProps(props); | ||
</script> |
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,22 +1,103 @@ | ||
<template> | ||
<bx-expandable-tile> | ||
<bx-tile-above-the-fold-content slot="above-the-fold-content"> | ||
<slot> | ||
<!-- Above the fold content here --> | ||
</slot> | ||
</bx-tile-above-the-fold-content> | ||
<bx-tile-below-the-fold-content> | ||
<slot name="below"> Below the fold content here </slot> | ||
</bx-tile-below-the-fold-content> | ||
</bx-expandable-tile> | ||
<button | ||
type="button" | ||
:style="data.styleObject" | ||
@click="toggle" | ||
:class="[ | ||
`cv-tile-expandable ${carbonPrefix}--tile--expandable`, | ||
{ [`${carbonPrefix}--tile--is-expanded`]: data.internalExpanded }, | ||
]" | ||
ref="el" | ||
> | ||
<div :class="`${carbonPrefix}--tile-content`"> | ||
<span | ||
data-tile-atf | ||
:class="`${carbonPrefix}--tile-content__above-the-fold`" | ||
ref="aboveFold" | ||
> | ||
<slot> | ||
<!-- Above the fold content here --> | ||
</slot> | ||
</span> | ||
<div :class="`${carbonPrefix}--tile__chevron`"> | ||
<span>{{ chevronLabel }}</span> | ||
<ChevronDown16 /> | ||
</div> | ||
<span | ||
:class="`${carbonPrefix}--tile-content__below-the-fold`" | ||
ref="belowFold" | ||
v-show="data.internalExpanded || data.initialized" | ||
> | ||
<slot name="below"> | ||
<!-- Rest of the content here --> | ||
</slot> | ||
</span> | ||
</div> | ||
</button> | ||
</template> | ||
|
||
<script setup> | ||
import '@carbon/web-components/es/components/tile/index.js'; | ||
import { carbonPrefix } from '../../global/settings'; | ||
import ChevronDown16 from '@carbon/icons-vue/es/chevron--down/16'; | ||
import { computed, nextTick, reactive, ref, watch } from 'vue'; | ||
defineProps({ | ||
const props = defineProps({ | ||
expanded: Boolean, | ||
tileCollapsedLabel: String, | ||
tileExpandedLabel: String, | ||
}); | ||
const data = reactive({ | ||
styleObject: { | ||
maxHeight: 'initial', | ||
}, | ||
initialized: false, | ||
internalExpanded: props.expanded, | ||
}); | ||
watch( | ||
() => props.expanded, | ||
val => { | ||
if (val !== data.internalExpanded) { | ||
toggle(val); | ||
} | ||
} | ||
); | ||
const chevronLabel = computed(() => { | ||
return data.internalExpanded | ||
? props.tileExpandedLabel | ||
: props.tileCollapsedLabel; | ||
}); | ||
const el = ref(null); | ||
const belowFold = ref(null); | ||
function toggle(force) { | ||
let currentHeight = el?.value.getBoundingClientRect().height; | ||
if (!data.initialized) { | ||
data.styleObject.maxHeight = `${currentHeight}px`; | ||
data.initialized = true; | ||
} | ||
nextTick(() => { | ||
const forceType = typeof force; | ||
data.internalExpanded = | ||
forceType === 'boolean' ? force : !data.internalExpanded; | ||
const belowFoldHeight = belowFold?.value.getBoundingClientRect().height; | ||
if (data.internalExpanded) { | ||
currentHeight += belowFoldHeight; | ||
} else { | ||
currentHeight -= belowFoldHeight; | ||
} | ||
data.styleObject.maxHeight = `${currentHeight}px`; | ||
}); | ||
} | ||
const emit = defineEmits(['expanded']); | ||
watch( | ||
() => data.internalExpanded, | ||
val => { | ||
emit('expanded', val); | ||
} | ||
); | ||
</script> |
Oops, something went wrong.