Skip to content

Commit

Permalink
Front: Better padding + text color for chips
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthi-chaud authored and zoriya committed Dec 7, 2023
1 parent bf831db commit ee3eed6
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
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

0 comments on commit ee3eed6

Please sign in to comment.