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

Front: Better padding + text color for chips #237

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions front/packages/primitives/src/chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ export const Chip = <AsProps = { label: string },>({
[
{
pY: ts(1 * sizeMult),
pX: ts(1.5 * sizeMult),
pX: ts(2.5 * sizeMult),
borderRadius: ts(3),
fontSize: rem(0.8),
},
!outline && {
color: (theme: Theme) => theme.contrast,
color: (theme: Theme) => theme.alternate.contrast,
bg: color ?? ((theme: Theme) => theme.accent),
},
outline && {
Expand Down
32 changes: 32 additions & 0 deletions front/packages/primitives/src/utils/capitalize.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Kyoo - A portable and vast media library solution.
* Copyright (c) Kyoo.
*
* See AUTHORS.md and LICENSE file in the project root for full license information.
*
* Kyoo is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Kyoo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
*/

export const capitalize = (str: string): string => {
return str
.split(" ")
.map((s) => s.trim())
.map((s) => {
if (s.length > 1) {
return s.charAt(0).toUpperCase() + s.slice(1);
}
return s;
})
.join(" ");
};
1 change: 1 addition & 0 deletions front/packages/primitives/src/utils/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ export * from "./breakpoints";
export * from "./nojs";
export * from "./head";
export * from "./spacing";
export * from "./capitalize";
10 changes: 8 additions & 2 deletions front/packages/ui/src/details/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import { Rating } from "../components/rating";
import { EpisodeLine, displayRuntime, episodeDisplayNumber } from "./episode";
import { WatchListInfo } from "../components/watchlist-info";
import { ShowWatchStatus, WatchStatusV } from "@kyoo/models/src/resources/watch-status";
import { capitalize } from "@kyoo/primitives";

export const TitleLine = ({
isLoading,
Expand Down Expand Up @@ -366,7 +367,12 @@ const Description = ({
>
<P {...css({ marginRight: ts(0.5) })}>{t("show.tags")}:</P>
{(isLoading ? [...Array<string>(3)] : tags!).map((tag, i) => (
<Chip key={tag ?? i} label={tag} size="small" {...css({ m: ts(0.5) })} />
<Chip
key={tag ?? i}
label={tag && capitalize(tag)}
size="small"
{...css({ m: ts(0.5) })}
/>
))}
</View>
</View>
Expand Down Expand Up @@ -472,7 +478,7 @@ export const Header = ({
},
}) as any)}
>
{data ? name : <Skeleton {...css({ width: rem(3) })} />}
{data ? capitalize(name) : <Skeleton {...css({ width: rem(3) })} />}
</Chip>
))}
</Container>
Expand Down
Loading