From 5682cf2c221ebc04bf1c7158f4acb93866a9e212 Mon Sep 17 00:00:00 2001 From: Romain Lenzotti Date: Tue, 6 Aug 2024 13:57:26 +0200 Subject: [PATCH] fix(home): improve responsive layout --- .github/workflows/build.yml | 4 +- .github/workflows/website.yml | 2 +- .../theme/atoms/svg/MessageCircleHeart.vue | 17 ++ .../theme/composables/randomize/useRandom.ts | 54 +++++++ docs/.vitepress/theme/index.ts | 10 +- .../theme/molecules/frameworks/Frameworks.vue | 91 +++++++++++ .../theme/molecules/partners/Partners.vue | 57 +++++++ .../theme/organisms/frameworks/Frameworks.vue | 146 ------------------ .../theme/organisms/home/ButtonBanner.vue | 4 +- .../theme/organisms/home/HomeBanner.vue | 12 +- .../theme/organisms/home/HomeBody.vue | 33 ++++ .../theme/organisms/home/HomeContainer.vue | 60 +++++++ .../theme/organisms/home/HomeFrameworks.vue | 22 +++ .../theme/organisms/home/HomePartners.vue | 38 +++++ docs/.vitepress/theme/style.css | 92 +++++++++++ docs/index.md | 30 +++- docs/public/partners/clubmed.svg | 4 + docs/public/partners/egain.webp | Bin 0 -> 4844 bytes docs/public/partners/schnell.svg | 19 +++ docs/public/partners/zenika.svg | 26 ++++ vitest.config.ts | 8 +- 21 files changed, 557 insertions(+), 172 deletions(-) create mode 100644 docs/.vitepress/theme/atoms/svg/MessageCircleHeart.vue create mode 100644 docs/.vitepress/theme/composables/randomize/useRandom.ts create mode 100644 docs/.vitepress/theme/molecules/frameworks/Frameworks.vue create mode 100644 docs/.vitepress/theme/molecules/partners/Partners.vue delete mode 100644 docs/.vitepress/theme/organisms/frameworks/Frameworks.vue create mode 100644 docs/.vitepress/theme/organisms/home/HomeBody.vue create mode 100644 docs/.vitepress/theme/organisms/home/HomeContainer.vue create mode 100644 docs/.vitepress/theme/organisms/home/HomeFrameworks.vue create mode 100644 docs/.vitepress/theme/organisms/home/HomePartners.vue create mode 100644 docs/public/partners/clubmed.svg create mode 100644 docs/public/partners/egain.webp create mode 100644 docs/public/partners/schnell.svg create mode 100644 docs/public/partners/zenika.svg diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ae0752a..3e945e6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -59,10 +59,10 @@ jobs: with: node-version: 20 cache: yarn - - name: Install Playwright 🚀 - run: npx playwright install --with-deps - name: Install dependencies 🚀 run: yarn install --immutable + - name: Install Playwright 🚀 + run: yarn playwright install - name: Build Storybook run: yarn storybook:build --quiet - name: Serve Storybook and run tests 🔍 diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index ef835e6..cb3130f 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -45,7 +45,7 @@ jobs: run: | yarn docs:build touch docs/.vitepress/dist/.nojekyll - echo "beta.tsed.io" > docs/.vitepress/dist/CNAME + echo "beta.tsed.dev" > docs/.vitepress/dist/CNAME - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: diff --git a/docs/.vitepress/theme/atoms/svg/MessageCircleHeart.vue b/docs/.vitepress/theme/atoms/svg/MessageCircleHeart.vue new file mode 100644 index 0000000..a03dc10 --- /dev/null +++ b/docs/.vitepress/theme/atoms/svg/MessageCircleHeart.vue @@ -0,0 +1,17 @@ + diff --git a/docs/.vitepress/theme/composables/randomize/useRandom.ts b/docs/.vitepress/theme/composables/randomize/useRandom.ts new file mode 100644 index 0000000..8304066 --- /dev/null +++ b/docs/.vitepress/theme/composables/randomize/useRandom.ts @@ -0,0 +1,54 @@ +import {ref} from "vue"; + +export interface UseRandomProps { + initItems: Data[]; + maxItems: number; + numberToChange: number; +} + +const getRandomIndex = (arrayLength: number) => { + if (arrayLength === 0) { + return 0; + } + return Math.floor(Math.random() * arrayLength); +}; + +export function useRandomItems({initItems, maxItems, numberToChange}: UseRandomProps) { + const randomItems = ref([]); + const shuffledItems = ref([]); + const lastChangedIndex = ref(-1); + + function update() { + if (initItems.length > 0) { + // Si randomItems est vide, remplir initialement avec 10 éléments aléatoires + if (randomItems.value.length === 0) { + shuffledItems.value = initItems.sort(() => 0.5 - Math.random()) as never; + + randomItems.value = shuffledItems.value.slice(0, maxItems); + } else { + const currentList = [...randomItems.value]; + + // Remplacer partiellement les éléments existants + for (let i = 0; i < numberToChange; i++) { + let randomItemIndex = getRandomIndex(currentList.length); + + while (lastChangedIndex.value === randomItemIndex) { + randomItemIndex = getRandomIndex(currentList.length); + } + + lastChangedIndex.value = randomItemIndex; + + const item = shuffledItems.value.pop()!; + + shuffledItems.value.unshift(currentList[randomItemIndex]); + + currentList[randomItemIndex] = item; + } + + randomItems.value = currentList; + } + } + } + + return {update, lastChangedIndex, items: randomItems}; +} diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts index b9aa7d8..2019b5b 100644 --- a/docs/.vitepress/theme/index.ts +++ b/docs/.vitepress/theme/index.ts @@ -13,13 +13,17 @@ import CodeSandbox from "./molecules/codesandbox/CodeSandbox.vue"; import Projects from "./organisms/projects/Projects.vue"; import Banner from "./molecules/banner/Banner.vue"; import HomeBanner from "./organisms/home/HomeBanner.vue"; -import Frameworks from "./organisms/frameworks/Frameworks.vue"; +import HomePartners from "./organisms/home/HomePartners.vue"; +import HomeFrameworks from "./organisms/home/HomeFrameworks.vue"; +import HomeBody from "./organisms/home/HomeBody.vue"; export default { extends: DefaultTheme, Layout: () => { return h(DefaultTheme.Layout, null, { - "home-hero-image": () => h(HomeBanner) + "home-hero-image": () => h(HomeBanner), + "home-features-before": () => h(HomePartners), + "home-features-after": () => h(HomeBody) // https://vitepress.dev/guide/extending-default-theme#layout-slots }); }, @@ -29,7 +33,7 @@ export default { app.component("GithubContributors", GithubContributors); app.component("CodeSandbox", CodeSandbox); app.component("Projects", Projects); - app.component("Frameworks", Frameworks); + app.component("HomeFrameworks", HomeFrameworks); // eslint-disable-next-line vue/no-reserved-component-names app.component("Button", Button); app.component("Banner", Banner); diff --git a/docs/.vitepress/theme/molecules/frameworks/Frameworks.vue b/docs/.vitepress/theme/molecules/frameworks/Frameworks.vue new file mode 100644 index 0000000..98702e1 --- /dev/null +++ b/docs/.vitepress/theme/molecules/frameworks/Frameworks.vue @@ -0,0 +1,91 @@ + + + diff --git a/docs/.vitepress/theme/molecules/partners/Partners.vue b/docs/.vitepress/theme/molecules/partners/Partners.vue new file mode 100644 index 0000000..dc1a898 --- /dev/null +++ b/docs/.vitepress/theme/molecules/partners/Partners.vue @@ -0,0 +1,57 @@ + + + diff --git a/docs/.vitepress/theme/organisms/frameworks/Frameworks.vue b/docs/.vitepress/theme/organisms/frameworks/Frameworks.vue deleted file mode 100644 index 7466e21..0000000 --- a/docs/.vitepress/theme/organisms/frameworks/Frameworks.vue +++ /dev/null @@ -1,146 +0,0 @@ - - - diff --git a/docs/.vitepress/theme/organisms/home/ButtonBanner.vue b/docs/.vitepress/theme/organisms/home/ButtonBanner.vue index b18def1..55fadbe 100644 --- a/docs/.vitepress/theme/organisms/home/ButtonBanner.vue +++ b/docs/.vitepress/theme/organisms/home/ButtonBanner.vue @@ -16,10 +16,10 @@ const props = withDefaults(defineProps(), {}); >
- {{ props.title }} + {{ props.title }}
- +
diff --git a/docs/.vitepress/theme/organisms/home/HomeBanner.vue b/docs/.vitepress/theme/organisms/home/HomeBanner.vue index 42560ed..03dd50a 100644 --- a/docs/.vitepress/theme/organisms/home/HomeBanner.vue +++ b/docs/.vitepress/theme/organisms/home/HomeBanner.vue @@ -13,9 +13,9 @@ const {formattedStargazers, fetchStargazers} = useStargazers(githubProxyUrl, 280 fetchStargazers();