Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Fix/426 pictures are not shown in the right places #573

Merged
merged 35 commits into from
Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
669f243
fix: create new cms component
Michal-Dziedzinski Mar 19, 2020
b8cb334
Merge branch 'master' into fix/509-cms-two-columns-boxed
Michal-Dziedzinski Mar 19, 2020
53958b3
fix: remove ::v-deep directive
Michal-Dziedzinski Mar 19, 2020
72810a3
fix: fix different cms looks
Michal-Dziedzinski Mar 23, 2020
00d63a4
fix: tests added
Michal-Dziedzinski Mar 25, 2020
3ca4ab2
Merge branch 'master' into fix/509-cms-two-columns-boxed
Michal-Dziedzinski Mar 26, 2020
565ccb6
fix: add SwImageTwoColumn component
Michal-Dziedzinski Mar 30, 2020
0024b71
fix: add SwImageThreeColumn component
Michal-Dziedzinski Mar 30, 2020
ab758d7
fix: add SwImageThreeColumn component
Michal-Dziedzinski Mar 30, 2020
d310609
fix: add SwImageFourColumn component
Michal-Dziedzinski Mar 30, 2020
47a584e
fix: add SwImageHighLightRow component
Michal-Dziedzinski Mar 30, 2020
d2a33c1
fix: fix SwImageBubbleRow component
Michal-Dziedzinski Mar 31, 2020
7529ff5
fix: add SwImageSimpleGrid component
Michal-Dziedzinski Mar 31, 2020
822da4c
fix: add SwCenterText component
Michal-Dziedzinski Mar 31, 2020
331907e
fix: add unit tests
Michal-Dziedzinski Mar 31, 2020
9cc48d6
Merge branch 'master' into fix/426-pictures-are-not-shown-in-the-righ…
Michal-Dziedzinski Mar 31, 2020
0a722e4
fix: remove console.log
Michal-Dziedzinski Mar 31, 2020
e9e6195
fix: fix lint scripts and use prettier
Michal-Dziedzinski Apr 1, 2020
cf911fa
fix: add js notes to public interfaces, enums and functions
Michal-Dziedzinski Apr 1, 2020
2c81ee7
fix: changed md files
Michal-Dziedzinski Apr 1, 2020
897e343
Merge branch 'master' into fix/426-pictures-are-not-shown-in-the-righ…
Michal-Dziedzinski Apr 6, 2020
382c35a
fix: add SwImageTextCover
Michal-Dziedzinski Apr 6, 2020
7f87e46
Merge branch 'master' into fix/426-pictures-are-not-shown-in-the-righ…
Michal-Dziedzinski Apr 8, 2020
330a258
fix: set fixed height of images
Michal-Dziedzinski Apr 10, 2020
7ae691e
Merge branch 'master' into fix/426-pictures-are-not-shown-in-the-righ…
Michal-Dziedzinski Apr 10, 2020
f2f51fc
Merge branch 'master' into fix/426-pictures-are-not-shown-in-the-righ…
patzick Apr 15, 2020
d449c1f
Merge branch 'master' into fix/426-pictures-are-not-shown-in-the-righ…
Michal-Dziedzinski Apr 27, 2020
ff327e1
fix: update cms blocks after cms structure changes
Michal-Dziedzinski Apr 28, 2020
5f374bc
Merge branch 'master' into fix/426-pictures-are-not-shown-in-the-righ…
Michal-Dziedzinski Apr 28, 2020
fddd5e6
fix: fix height styles, improve html structure
Michal-Dziedzinski Apr 29, 2020
606ce69
Merge branch 'fix/426-pictures-are-not-shown-in-the-right-places' of …
Michal-Dziedzinski Apr 29, 2020
7489892
fix: include desktop-size mixin
Michal-Dziedzinski Apr 29, 2020
ebd9283
fix: add boxed size as modifikator for section default
Michal-Dziedzinski Apr 29, 2020
4c13663
Merge branch 'master' into fix/426-pictures-are-not-shown-in-the-righ…
patzick Apr 29, 2020
0837433
Apply suggestions from code review
patzick Apr 29, 2020
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
53 changes: 53 additions & 0 deletions api/composables.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
```ts

import { AddressType } from '@shopware-pwa/commons/interfaces/models/checkout/customer/CustomerAddress';
import { CmsSlot } from '@shopware-pwa/commons/interfaces/models/content/cms/CmsPage';
import { Country } from '@shopware-pwa/commons/interfaces/models/system/country/Country';
import { Customer } from '@shopware-pwa/commons/interfaces/models/checkout/customer/Customer';
import { CustomerAddress } from '@shopware-pwa/commons/interfaces/models/checkout/customer/CustomerAddress';
Expand Down Expand Up @@ -52,6 +53,24 @@ export function createCheckoutStep({ stepNumber, stepFields, stepDataUpdated, }:
// @alpha (undocumented)
export function getStore(): any;

// @alpha (undocumented)
export enum PositionType {
// (undocumented)
CENTER = "center",
// (undocumented)
CENTER_LEFT = "center-left",
// (undocumented)
CENTER_RIGHT = "center-right",
// (undocumented)
LEFT = "left",
// (undocumented)
LEFT_BOTTOM = "left-bottom",
// (undocumented)
LEFT_TOP = "left-top",
// (undocumented)
RIGHT = "right"
}

// @alpha (undocumented)
export type Search = (path: string, associations?: any) => any;

Expand Down Expand Up @@ -125,6 +144,19 @@ export interface UseCountries {
// @alpha (undocumented)
export const useCountries: () => UseCountries;

// @alpha (undocumented)
export interface UseImageProps {
// (undocumented)
getAlt: Ref<Readonly<any>>;
// (undocumented)
getImgUrl: Ref<Readonly<any>>;
// (undocumented)
getTitle: Ref<Readonly<any>>;
}

// @alpha (undocumented)
export const useImageProps: (content: CmsSlot | undefined) => UseImageProps;

// @alpha (undocumented)
export const useNavigation: () => any;

Expand Down Expand Up @@ -201,6 +233,27 @@ export interface UseSessionContext {
// @alpha (undocumented)
export const useSessionContext: () => UseSessionContext;

// @alpha (undocumented)
export interface UseSlotsPositions {
// (undocumented)
centerLeftSlot: Ref<Readonly<CmsSlot | undefined>>;
// (undocumented)
centerRightSlot: Ref<Readonly<CmsSlot | undefined>>;
// (undocumented)
centerSlot: Ref<Readonly<CmsSlot | undefined>>;
// (undocumented)
leftBottomSlot: Ref<Readonly<CmsSlot | undefined>>;
// (undocumented)
leftSlot: Ref<Readonly<CmsSlot | undefined>>;
// (undocumented)
leftTopSlot: Ref<Readonly<CmsSlot | undefined>>;
// (undocumented)
rightSlot: Ref<Readonly<CmsSlot | undefined>>;
}

// @alpha (undocumented)
export const useSlotsPositions: (slots: CmsSlot[]) => UseSlotsPositions;

// @alpha (undocumented)
export interface UseUser {
// (undocumented)
Expand Down
2 changes: 1 addition & 1 deletion api/helpers.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export function getCmsSections(content: CmsPage): CmsSection[];
// @alpha (undocumented)
export const getFilterSearchCriteria: (selectedFilters: any) => any[];

// @public
// @alpha
export function getMessagesFromErrorsArray(errors: ShopwareError[]): string[];

// Warning: (ae-forgotten-export) The symbol "NavigationRoute" needs to be exported by the entry point index.d.ts
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"dev:debug": "node --inspect scripts/dev.js",
"build": "node scripts/build.js",
"postinstall": "node scripts/linkDependencies.js && lerna link",
"lint": "prettier --write --parser typescript 'packages/**/*.ts'",
"lint": "prettier --write --parser typescript \"packages/**/*.ts\"",
"test": "jest",
"test:e2e": "jest --e2e=true --runInBand",
"test:coverage": "yarn test --coverage",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/templates/shopware-pwa.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
shopwareEndpoint: "<%= props.shopwareEndpoint %>",
shopwareAccessToken: "<%= props.shopwareAccessToken %>",
shopwareAccessToken: "<%= props.shopwareAccessToken %>"
patzick marked this conversation as resolved.
Show resolved Hide resolved
};
12 changes: 12 additions & 0 deletions packages/commons/interfaces/models/content/cms/CmsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,31 @@ export interface CmsBlock {
slots: CmsSlot[];
}

/**
* @alpha
*/
export enum SectionType {
DEFAULT = "default",
}

/**
* @alpha
*/
export enum SizingMode {
BOXED = "boxed",
}

/**
* @alpha
*/
export enum MobileBehavior {
BOXED = "boxed",
WRAP = "wrap",
}

/**
* @alpha
*/
export enum BackgroundMediaMode {
COVER = "cover",
}
Expand Down
48 changes: 48 additions & 0 deletions packages/composables/__tests__/cms/useImageProps.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import Vue from "vue";
import VueCompositionApi from "@vue/composition-api";
Vue.use(VueCompositionApi);

import { useImageProps } from "@shopware-pwa/composables";

describe("Composables - useImageProps", () => {
const content = {
data: {
media: {
title: "title",
alt: "alternative text",
url: "image-url",
},
},
};

const emptyContent = undefined;

it("should return computed url string", () => {
const { getImgUrl } = useImageProps(content as any);
expect(getImgUrl.value).toBe("image-url");
});

it("should return computed title string", () => {
const { getTitle } = useImageProps(content as any);
expect(getTitle.value).toBe("title");
});

it("should return computed alt string", () => {
const { getAlt } = useImageProps(content as any);
expect(getAlt.value).toBe("alternative text");
});
it("should return empty string", () => {
const { getImgUrl } = useImageProps(emptyContent as any);
expect(getImgUrl.value).toBe("");
});

it("should return empty string", () => {
const { getTitle } = useImageProps(emptyContent as any);
expect(getTitle.value).toBe("");
});

it("should return empty string", () => {
const { getAlt } = useImageProps(emptyContent as any);
expect(getAlt.value).toBe("");
});
});
108 changes: 108 additions & 0 deletions packages/composables/__tests__/cms/useSlotPositions.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import Vue from "vue";
import VueCompositionApi from "@vue/composition-api";
Vue.use(VueCompositionApi);

import { useSlotsPositions } from "@shopware-pwa/composables";

describe("Composables - useImageProps", () => {
const slots = [
{
slot: "right",
},
{
slot: "left",
},
{
slot: "center",
},
{
slot: "center-left",
},
{
slot: "center-right",
},
{
slot: "left-top",
},
{
slot: "left-bottom",
},
];

const fakeSlots = [
{
slot: "this",
},
{
slot: "is",
},
{
slot: "just",
},
{
slot: "a",
},
{
slot: "test",
},
];

it("should return computed CmsSlot which contains slot hey wit left value", () => {
const { leftSlot } = useSlotsPositions(slots as any);
expect(leftSlot.value).toMatchObject({ slot: "left" });
});

it("should return computed title string", () => {
const { rightSlot } = useSlotsPositions(slots as any);
expect(rightSlot.value).toMatchObject({ slot: "right" });
});

it("should return computed alt string", () => {
const { centerSlot } = useSlotsPositions(slots as any);
expect(centerSlot.value).toMatchObject({ slot: "center" });
});
it("should return computed url string", () => {
const { centerLeftSlot } = useSlotsPositions(slots as any);
expect(centerLeftSlot.value).toMatchObject({ slot: "center-left" });
});

it("should return computed title string", () => {
const { centerRightSlot } = useSlotsPositions(slots as any);
expect(centerRightSlot.value).toMatchObject({ slot: "center-right" });
});

it("should return computed alt string", () => {
const { leftTopSlot } = useSlotsPositions(slots as any);
expect(leftTopSlot.value).toMatchObject({ slot: "left-top" });
});
it("should return computed alt string", () => {
const { leftBottomSlot } = useSlotsPositions(slots as any);
expect(leftBottomSlot.value).toMatchObject({ slot: "left-bottom" });
});
it("should return empty string", () => {
const { leftSlot } = useSlotsPositions(fakeSlots as any);
expect(leftSlot.value).toBe(undefined);
});

it("should return empty string", () => {
const { centerSlot } = useSlotsPositions(fakeSlots as any);
expect(centerSlot.value).toBe(undefined);
});

it("should return empty string", () => {
const { centerLeftSlot } = useSlotsPositions(fakeSlots as any);
expect(centerLeftSlot.value).toBe(undefined);
});
it("should return empty string", () => {
const { centerRightSlot } = useSlotsPositions(fakeSlots as any);
expect(centerRightSlot.value).toBe(undefined);
});
it("should return empty string", () => {
const { leftTopSlot } = useSlotsPositions(fakeSlots as any);
expect(leftTopSlot.value).toBe(undefined);
});
it("should return empty string", () => {
const { leftBottomSlot } = useSlotsPositions(fakeSlots as any);
expect(leftBottomSlot.value).toBe(undefined);
});
});
35 changes: 35 additions & 0 deletions packages/composables/src/cms/useImageProps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { computed, Ref } from "@vue/composition-api";
import { CmsSlot } from "@shopware-pwa/commons/interfaces/models/content/cms/CmsPage";

/**
* @alpha
*/
export interface UseImageProps {
getImgUrl: Ref<Readonly<any>>;
getAlt: Ref<Readonly<any>>;
getTitle: Ref<Readonly<any>>;
}

/**
* @alpha
*/
export const useImageProps = (content: CmsSlot | undefined): UseImageProps => {
const getImgUrl = computed(() => {
const imgUrl = content?.data?.media?.url;
return imgUrl || "";
});
const getAlt = computed(() => {
const alt = content?.data?.media?.alt;
return alt || "";
});
const getTitle = computed(() => {
const title = content?.data?.media?.title;
return title || "";
});

return {
getImgUrl,
getAlt,
getTitle,
};
};
68 changes: 68 additions & 0 deletions packages/composables/src/cms/useSlotsPositions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { computed, Ref } from "@vue/composition-api";
import { CmsSlot } from "@shopware-pwa/commons/interfaces/models/content/cms/CmsPage";

/**
* @alpha
*/
export interface UseSlotsPositions {
leftSlot: Ref<Readonly<CmsSlot | undefined>>;
rightSlot: Ref<Readonly<CmsSlot | undefined>>;
centerSlot: Ref<Readonly<CmsSlot | undefined>>;
centerLeftSlot: Ref<Readonly<CmsSlot | undefined>>;
centerRightSlot: Ref<Readonly<CmsSlot | undefined>>;
leftTopSlot: Ref<Readonly<CmsSlot | undefined>>;
leftBottomSlot: Ref<Readonly<CmsSlot | undefined>>;
}

/**
* @alpha
*/
export enum PositionType {
LEFT = "left",
RIGHT = "right",
CENTER = "center",
CENTER_LEFT = "center-left",
CENTER_RIGHT = "center-right",
LEFT_TOP = "left-top",
LEFT_BOTTOM = "left-bottom",
}

/**
* @alpha
*/
export const useSlotsPositions = (slots: CmsSlot[]): UseSlotsPositions => {
const findSlot = (positionType: PositionType): CmsSlot | undefined =>
slots.find(({ slot }) => slot === positionType);

const leftSlot = computed((): CmsSlot | undefined =>
findSlot(PositionType.LEFT)
);
const rightSlot = computed((): CmsSlot | undefined =>
findSlot(PositionType.RIGHT)
);
const centerSlot = computed((): CmsSlot | undefined =>
findSlot(PositionType.CENTER)
);
const centerLeftSlot = computed((): CmsSlot | undefined =>
findSlot(PositionType.CENTER_LEFT)
);
const centerRightSlot = computed((): CmsSlot | undefined =>
findSlot(PositionType.CENTER_RIGHT)
);
const leftTopSlot = computed((): CmsSlot | undefined =>
findSlot(PositionType.LEFT_TOP)
);
const leftBottomSlot = computed((): CmsSlot | undefined =>
findSlot(PositionType.LEFT_BOTTOM)
);

return {
leftSlot,
rightSlot,
centerSlot,
centerLeftSlot,
centerRightSlot,
leftBottomSlot,
leftTopSlot,
};
};
Loading