Skip to content

Commit

Permalink
feat(molecules): add stargazerUrl and defaultStargazerValue to config…
Browse files Browse the repository at this point in the history
…uration
  • Loading branch information
Romakita committed Nov 30, 2024
1 parent 6cf7d76 commit afefa63
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ export interface CustomThemeConfig {
apiRedirectUrl: string;
repo: string;
githubProxyUrl: string;
stargazerUrl?: string;
coveragePercentage?: string;
defaultStargazerValue?: number;
}
26 changes: 17 additions & 9 deletions packages/theme/organisms/home/HomeBanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,32 @@
import ButtonBanner from "./ButtonBanner.vue";
import {useStargazers} from "../../composables/api/useStargazers";
import {useThemeConfig} from "../../composables/config/useThemeConfig";
import {formatNumber} from "../../utils/format";
const theme = useThemeConfig();
const {githubProxyUrl} = theme.value;
const {
githubProxyUrl,
stargazerUrl,
defaultStargazerValue = 2800,
coveragePercentage = 98,
repo
} = theme.value;
const {formattedStargazers, fetchStargazers} = useStargazers(githubProxyUrl, 2800);
const {data} = useStargazers(stargazerUrl || githubProxyUrl);
const repoHref = `https://github.com/${repo}`;
fetchStargazers();
</script>
<template>
<div class="vp-doc m-auto w-[90%] sm:w-full lg:w-[75%] mt-10">
<slot />
<slot/>

<div class="flex justify-between space-x-2 -mx-[24px] md:mx-0">
<ButtonBanner href="https://github.com/tsedio/tsed/stargazers" title="stars">{{
formattedStargazers
}}</ButtonBanner>
<ButtonBanner href="https://github.com/tsedio/tsed" title="Coverage">98%</ButtonBanner>
<ButtonBanner href="https://github.com/tsedio/tsed/blob/production/LICENSE" title="License">
<ButtonBanner :href="repoHref + '/stargazers'" title="stars">{{
data?.formattedStargazers || formatNumber(defaultStargazerValue)
}}
</ButtonBanner>
<ButtonBanner :href="repoHref" title="Coverage">{{coveragePercentage}}%</ButtonBanner>
<ButtonBanner :href="repoHref + '/blob/production/LICENSE'" title="License">
<template #title>License</template>
MIT
</ButtonBanner>
Expand Down
4 changes: 2 additions & 2 deletions packages/theme/organisms/warehouse/Warehouse.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const Default: Story = {

const clearableFilter = screen.getByTestId("ClearableFilter");

await expect(within(clearableFilter).getByText(/plugins/)).toHaveTextContent("126 plugins found");
await expect(within(clearableFilter).getByText(/plugins/)).toHaveTextContent("125 plugins found");

await expect(screen.getByText("@tsed/logger")).toBeInTheDocument();
await expect(screen.getByText("@tsed/exceptions")).toBeInTheDocument();
Expand Down Expand Up @@ -62,6 +62,6 @@ export const Default: Story = {

await userEvent.click(clearFilter, {delay: 500});

await expect(within(clearableFilter).getByText(/plugins/)).toHaveTextContent("126 plugins found");
await expect(within(clearableFilter).getByText(/plugins/)).toHaveTextContent("125 plugins found");
}
};
1 change: 1 addition & 0 deletions packages/theme/styles/algolia.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
}

.dark {
.VPNavBar.top.home .DocSearch-Button,
.VPNavBar .DocSearch-Button {
@apply transition-all ease-in-out duration-200 rounded-full;
background: rgba(120, 131, 155, .2);
Expand Down
6 changes: 3 additions & 3 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ export default defineConfig({
enabled: true,
thresholds: {
autoUpdate: true,
statements: 64.6,
branches: 78.89,
statements: 64.1,
branches: 78.28,
functions: 61.29,
lines: 64.6
lines: 64.1
},
include: ["**/*.{ts,vue}"],
exclude: [
Expand Down

0 comments on commit afefa63

Please sign in to comment.