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

Media Object #192

Merged
merged 108 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 106 commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
eaef5d0
progress check
sikhote Apr 19, 2024
171ce20
progress check
sikhote Apr 23, 2024
ec128b8
progress check
sikhote Apr 24, 2024
48dd0ab
progress check
sikhote Apr 24, 2024
a89f272
progress check
sikhote Apr 30, 2024
bd01061
progress check
sikhote May 1, 2024
30d4ff9
progress check
sikhote May 31, 2024
2b9f0fc
progress check
sikhote May 31, 2024
ca1aa2a
progress check
sikhote May 31, 2024
2cf92b0
progress check
sikhote Jun 3, 2024
ec3f7aa
progress check
sikhote Jun 3, 2024
be88487
progress check
sikhote Jun 4, 2024
4750555
progress check
sikhote Jun 18, 2024
c51959e
progress check
sikhote Jun 20, 2024
b57035e
progress check
sikhote Jun 25, 2024
8e00b52
progress check
sikhote Jul 2, 2024
c338043
progress check
sikhote Jul 2, 2024
a0e9fe7
test complete
sikhote Jul 10, 2024
bc211dd
merge main
sikhote Jul 25, 2024
f740d08
progress
sikhote Jul 25, 2024
1a3ac56
progress
sikhote Jul 30, 2024
beee45d
progress
sikhote Jul 31, 2024
41e8d48
progress
sikhote Aug 5, 2024
3939f28
progress
sikhote Aug 5, 2024
8bd16de
progress
sikhote Aug 5, 2024
7d8018d
progress
sikhote Aug 19, 2024
4d2eead
progress
sikhote Aug 19, 2024
a524543
progress
sikhote Aug 19, 2024
9879074
progress
sikhote Aug 19, 2024
384b32c
progress
sikhote Aug 19, 2024
ef9bd15
progress
sikhote Aug 20, 2024
b747723
progress
sikhote Aug 20, 2024
2749010
progress
sikhote Aug 20, 2024
f7bc529
progress
sikhote Aug 20, 2024
9d22ce5
progress
sikhote Aug 22, 2024
007178d
progress
sikhote Aug 22, 2024
d13f9c3
progress
sikhote Aug 22, 2024
0f7fb82
progress
sikhote Aug 22, 2024
e10f7e0
progress
sikhote Aug 22, 2024
7c88cd4
progress
sikhote Aug 27, 2024
bf708d8
progress
sikhote Aug 27, 2024
69cb4e6
progress
sikhote Aug 27, 2024
5ce6314
progress
sikhote Aug 27, 2024
bee7e6e
progress
sikhote Aug 27, 2024
3581983
progress
sikhote Aug 27, 2024
3633922
progress
sikhote Aug 27, 2024
71ff96a
progress
sikhote Aug 28, 2024
ca1ffdc
progress
sikhote Aug 29, 2024
1735e58
progress
sikhote Aug 29, 2024
f5411dc
progress
sikhote Aug 29, 2024
78f3591
progress
sikhote Aug 29, 2024
be80bff
progress
sikhote Aug 30, 2024
cc2b7a5
progress
sikhote Sep 3, 2024
905a6ad
progress
sikhote Sep 3, 2024
10b8f05
progress
sikhote Sep 3, 2024
7bc063e
progress
sikhote Sep 3, 2024
8465cef
progress
sikhote Sep 3, 2024
86a13fb
media object
sikhote Sep 9, 2024
7f959de
Merge branch 'main' of github.com:rei/rei-cedar into pr/media-object
sikhote Oct 2, 2024
19d0adf
media object
sikhote Oct 2, 2024
cab99e8
media-object
sikhote Oct 17, 2024
d2bbf3c
media-object
sikhote Oct 17, 2024
f25e4b8
media-object
sikhote Oct 18, 2024
098508e
media-object
sikhote Oct 18, 2024
d5582e4
media-object
sikhote Oct 18, 2024
d21f183
media-object
sikhote Oct 18, 2024
b92a4f2
media-object
sikhote Oct 18, 2024
e869fcb
progress
sikhote Nov 6, 2024
fad20e9
layout integration
sikhote Nov 11, 2024
458509a
layout integration
sikhote Nov 11, 2024
f4c953a
merge master
sikhote Nov 11, 2024
df68ae8
cleanup
sikhote Nov 11, 2024
a1c5184
tests
sikhote Nov 11, 2024
60c9272
media-object-layout
sikhote Nov 18, 2024
13b5a06
media-object-layout
sikhote Nov 20, 2024
d5e7f9a
media-object-layout
sikhote Nov 21, 2024
80d60bd
media-object-layout
sikhote Nov 25, 2024
7a15177
media-object
sikhote Nov 25, 2024
a9b3802
Merge branch 'pr/media-object' of github.com:rei/rei-cedar into pr/me…
sikhote Nov 25, 2024
64c680c
media-object-layout
sikhote Nov 25, 2024
1bc06ce
media-object-layout
sikhote Dec 2, 2024
b27290b
media-object-layout
sikhote Dec 2, 2024
2b5db4f
media-object-layout
sikhote Dec 2, 2024
9686b6c
media-object-layout
sikhote Dec 6, 2024
a777f70
media-object-layout
sikhote Dec 6, 2024
d0ffa1c
media-object-layout tests
sikhote Dec 9, 2024
23d2965
media-object-layout e2e fixes
sikhote Dec 9, 2024
ad4ab9b
test
sikhote Dec 9, 2024
27b721f
test
sikhote Dec 9, 2024
2ab726b
test
sikhote Dec 9, 2024
ab82e38
test
sikhote Dec 9, 2024
47d5317
test
sikhote Dec 9, 2024
0e27aae
test
sikhote Dec 9, 2024
b279295
test
sikhote Dec 9, 2024
e28840d
test
sikhote Dec 9, 2024
c5f4564
test
sikhote Dec 9, 2024
9624b1a
test
sikhote Dec 9, 2024
cf83805
test
sikhote Dec 9, 2024
7e79070
test
sikhote Dec 9, 2024
e364d09
test
sikhote Dec 9, 2024
9659f76
media-object-layout e2e fixes
sikhote Dec 9, 2024
d94779a
media-object-layout e2e fixes
sikhote Dec 9, 2024
c409168
media-object-layout e2e fixes
sikhote Dec 9, 2024
5e5ecfd
media-object-layout type fixes
sikhote Dec 9, 2024
b3351c4
media-object-layout merge main
sikhote Dec 10, 2024
2327cd7
media-object-layout merge main
sikhote Dec 10, 2024
f35946d
media-object-layout media cover, examples
sikhote Dec 10, 2024
0e5adff
media-object-layout badge example
sikhote Dec 11, 2024
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
3,541 changes: 1,939 additions & 1,602 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@
"stylelint-config-standard-scss": "^13.1.0",
"stylelint-scss": "^6.8.1",
"ts-node": "^10.9.1",
"typescript": "^5.1.6",
"typescript": "5.6.3",
"vite": "^5.0.1",
"vite-plugin-dts": "^3.3.1",
"vitest": "^1.1.1",
"vue-docgen-cli": "^4.79.0",
"vue-eslint-parser": "^9.3.0",
"vue-router": "^4.0.10",
"vue-tsc": "^2.0.29"
"vue-tsc": "2.1.10"
},
"engines": {
"node": ">= 20.0.0",
Expand Down
4 changes: 2 additions & 2 deletions src/components/examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import landingLead from 'componentsdir/landingLead/examples/LandingLead.vue';
import layout from 'componentsdir/layout/examples/Layout.vue';
import links from 'componentsdir/link/examples/Links.vue';
import list from 'componentsdir/list/examples/Lists.vue';
// import mediaObject from 'componentsdir/mediaObject/examples/MediaObject.vue';
import mediaObject from 'componentsdir/mediaObject/examples/MediaObject.vue';
import modal from 'componentsdir/modal/examples/Modal.vue';
import pagination from 'componentsdir/pagination/examples/Pagination.vue';
import picture from 'componentsdir/picture/examples/Picture.vue';
Expand Down Expand Up @@ -67,7 +67,7 @@ export default {
layout,
links,
list,
// mediaObject,
mediaObject,
modal,
pagination,
picture,
Expand Down
6 changes: 4 additions & 2 deletions src/components/fulfillmentTile/CdrFulfillmentTileContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ const rootProps = computed(
(): bodyTextProps => ({
tag: 'div',
scale: props.scale,
class: [style[baseClass]],
}),
);
</script>

<template>
<CdrBody v-bind="rootProps">
<CdrBody
v-bind="rootProps"
:class="[style[baseClass]]"
>
<!-- @slot Where all default content should be placed. -->
<slot />
</CdrBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ const toggleCheckbox2 = (value: number) => {
class="example__search-tile-other-header-button"
:checked="checkbox2.includes(1)"
role="checkbox"
:layout="{ flow: 'rows' }"
:layout="{ flow: 'row' }"
@click="toggleCheckbox2(1)"
>
<CdrFulfillmentTileHeader>
Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/CdrLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const rootProps = computed(() => {

<template>
<component
:is="as"
:is="props.as"
v-bind="rootProps"
>
<!-- @slot Where all default content should be placed. -->
Expand Down
4 changes: 2 additions & 2 deletions src/components/layout/examples/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import CdrLayout from '../CdrLayout.vue';
import CdrSurface from '../../surface/CdrSurface.vue';
import CdrText from '../../text/CdrText.vue';
import type { Layout } from '../../../types/interfaces';
import type { Layout, HtmlAttributes } from '../../../types/interfaces';
defineOptions({ name: 'Layout' });
interface LayoutExample {
props: Layout;
props: Layout | HtmlAttributes;
children: number;
label: string;
isNarrow?: boolean;
Expand Down
119 changes: 119 additions & 0 deletions src/components/mediaObject/CdrMediaObject.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<script setup lang="ts">
import { useCssModule, computed } from 'vue';
import mapClasses from '../../utils/mapClasses';
import { MediaObject, NameValuePair, HtmlAttributes } from '../../types/interfaces';
import type { Breakpoint } from '../../types/other';
import { modifyClassName } from '../../utils/buildClass';
import { getLayoutStyling } from '../../utils/mediaObject';
import CdrLayout from '../layout/CdrLayout.vue';
import { breakpoints, spacing } from '../../utils/other';
mhewson marked this conversation as resolved.
Show resolved Hide resolved

/** Component for buttons that have a checked state. */

defineOptions({ name: 'CdrMediaObject' });

const props = withDefaults(defineProps<MediaObject>(), {
align: 'start',
mediaPosition: 'left',
mediaWidth: '1fr',
mediaHeight: 'auto',
cover: false,
mhewson marked this conversation as resolved.
Show resolved Hide resolved
overlay: false,
overlayRowAlign: 'start',
overlayColumnAlign: 'start',
contentPadding: 'zero',
});

const style = useCssModule();

const rootProps = computed(() => {
const baseClass = 'cdr-media-object';
const classes = [baseClass];
const inlineStyles: NameValuePair = {};
const {
align,
mediaPosition,
mediaWidth,
mediaHeight,
cover,
overlay,
overlayRowAlign,
overlayColumnAlign,
contentPadding,
...otherProps
} = props;
const additionalProps: HtmlAttributes = { ...otherProps };

if (contentPadding !== 'zero') {
if (typeof contentPadding === 'string') {
inlineStyles['--cdr-media-object-content-padding'] = spacing[contentPadding];
} else {
classes.push(modifyClassName(baseClass, 'content-padding-cq'));

breakpoints.forEach((breakpoint: Breakpoint) => {
// Add in padding styles for various breakpoints
inlineStyles[`--cdr-media-object-content-padding-${breakpoint}`] =
spacing[contentPadding[breakpoint]];
});
}
}

// Add overlay class, which skips most other props
mhewson marked this conversation as resolved.
Show resolved Hide resolved
if (overlay) {
classes.push(modifyClassName(baseClass, 'overlay'));
Object.assign(additionalProps, { rows: 'auto', columns: 'auto' });
inlineStyles['--cdr-media-object-row-align'] = overlayRowAlign;
inlineStyles['--cdr-media-object-column-align'] = overlayColumnAlign;
} else {
// Get layout related props and inline styles based on media measurements and
// content position, both of which can be dynamic
const layoutStyling = getLayoutStyling(mediaPosition, mediaWidth, mediaHeight);
Object.assign(inlineStyles, layoutStyling.inlineStyles);
Object.assign(additionalProps, layoutStyling.props);

// Add in class for allowing dynamic content positioning
if (typeof mediaPosition !== 'string') {
classes.push(modifyClassName(baseClass, 'media-position-cq'));
}

// Add align class and inline styles for allowing dynamic align values
// or set the static value
if (typeof align !== 'string') {
classes.push(modifyClassName(baseClass, 'align-cq'));

breakpoints.forEach((breakpoint: Breakpoint) => {
// Add in media position styles for various breakpoints
inlineStyles[`--cdr-media-object-align-${breakpoint}`] = align[breakpoint];
});
} else {
inlineStyles['--cdr-media-object-align'] = align;
}

// Add cover class
if (cover) {
classes.push(modifyClassName(baseClass, 'cover'));
}
}

return {
...additionalProps,
class: mapClasses(style, ...classes) || undefined,
style: inlineStyles,
};
});
</script>

<template>
<CdrLayout v-bind="rootProps">
<div :class="style['cdr-media-object__media']">
<!-- @slot Where the media should be placed. Should be a single node. -->
mhewson marked this conversation as resolved.
Show resolved Hide resolved
<slot name="media" />
</div>
<div :class="style['cdr-media-object__content']">
<!-- @slot Where all content should be placed. Can be multiple nodes. -->
<slot name="content" />
</div>
</CdrLayout>
</template>

<style lang="scss" module src="./styles/CdrMediaObject.module.scss"></style>
104 changes: 104 additions & 0 deletions src/components/mediaObject/__tests__/CdrMediaObject.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import { markRaw } from 'vue';
import { mount } from '../../../../test/vue-jest-style-workaround.js';
import CdrMediaObject from '../CdrMediaObject.vue';
import CdrSurface from '../../surface/CdrSurface.vue';

const CdrSurfaceRaw = markRaw(CdrSurface);

export const examples = [
{
label: 'default: media position left, media width 1fr, media height auto, align start',
props: {},
},
{
label: 'content padding',
props: { contentPadding: 'two-x' },
},
{
label: 'content padding dynamic',
props: { contentPadding: { xs: 'one-x', sm: 'one-x', md: 'three-x', lg: 'three-x' } },
},
{
label: 'media width 100px',
props: { mediaWidth: '100px' },
},
{
label: 'media width dynamic',
props: { mediaWidth: { xs: '100px', sm: '100px', md: '300px', lg: '300px' } },
},
{
label: 'align center',
props: { mediaWidth: 'auto', align: 'center' },
},
{
label: 'dynamic align',
props: { mediaWidth: 'auto', align: { xs: 'center', sm: 'center', md: 'end', lg: 'start' } },
},
{
label: 'cover',
props: { mediaWidth: '125px', cover: true },
},
{
label: 'media position right',
props: {
mediaPosition: 'right',
},
},
{
label: 'media position dynamic',
props: {
mediaPosition: { xs: 'top', sm: 'bottom', md: 'left', lg: 'right' },
},
},
{
label: 'media bottom',
props: {
mediaPosition: 'bottom',
},
},
{
label: 'media top, align center',
props: {
mediaPosition: 'top',
align: 'center',
},
},
{
label: 'media position dynamic, media height dynamic, media width dynamic',
props: {
mediaWidth: { xs: '100%', sm: '100%', md: '50%', lg: '75%' },
mediaHeight: { xs: '100px', sm: '200px', md: 'auto', lg: 'auto' },
mediaPosition: { xs: 'top', sm: 'top', md: 'left', lg: 'left' },
cover: true,
},
},
{
label: 'overlay, row align, column align, content configured independently to 50% width',
props: {
overlay: true,
overlayColumnAlign: 'end',
overlayRowAlign: 'center',
},
},
{
label: 'pass down props to Layout and Surface',
props: {
background: 'brand-spruce',
as: CdrSurfaceRaw,
},
},
];

describe('CdrMediaObject', () => {
describe('snapshot tests', () => {
examples.forEach(({ label, props }) => {
it(label, () => {
const wrapper = mount(CdrMediaObject, {
props,
slots: { content: 'Some content', media: 'Some media' },
});
expect(wrapper.element).toMatchSnapshot();
});
});
});
});
Loading
Loading