Skip to content

Commit

Permalink
feat: implement pinned feature
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshinorin committed Jul 21, 2024
1 parent a88db4d commit ae21e91
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 0 deletions.
6 changes: 6 additions & 0 deletions config.example.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ export const coverBottomItems = [
}
];

export const pinned = [
{ title: "title1", description: "example description1", url: "/" },
{ title: "title2", description: "example description2", url: "/" },
{ title: "title3", description: "example description3", url: "/" }
];

// NOTE: HTML support
export const copyrights = "© jhon due";

Expand Down
4 changes: 4 additions & 0 deletions src/app/renderer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { pinned } from "../../config";
import {
CoverComponent,
RecentArticlesComponent
} from "../components/components";
import { Pinned } from "../components/pinned";
import { Article } from "../models/models";
import containerStyles from "../styles/components/container.module.scss";
import styles from "../styles/home.module.scss";
Expand All @@ -15,6 +17,8 @@ export const Renderer: React.FunctionComponent<{
<main>
<div className={`${containerStyles.container} ${styles.wrap}`}>
<RecentArticlesComponent articles={articles} />
<hr />
<Pinned items={pinned} />
</div>
</main>
</>
Expand Down
1 change: 1 addition & 0 deletions src/components/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export * from "./headmeta";
export * from "./injectScript";
export * from "./navigation";
export * from "./pagination";
export * from "./pinned";
export * from "./planePage";
export * from "./searchResult";
export * from "./series";
Expand Down
17 changes: 17 additions & 0 deletions src/components/pinned.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import style from "../styles/components/pinned.module.scss";

export const Pinned: React.FunctionComponent<{ items }> = ({ items }) => {
return (
<div className={style["pinned"]}>
{items.map((item) => (
<a className="unstyled" href={item.url} target="_blank" key={item.url}>
<div className={style["pinned-card"]}>
<span className={style["title"]}>{item.title}</span>
<p className={style["description"]}>{item.description}</p>
<div className={style["link"]}></div>
</div>
</a>
))}
</div>
);
};
6 changes: 6 additions & 0 deletions src/styles/_themes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@

--home-background-color: #e4e4e4;

--pinned-background-color: #f7f7f7;
--pinned-border-color: #ddd;

--cover-background-color: #070b19;
--cover-title-color: #ffffff;
--cover-meta-color: #ffffff;
Expand Down Expand Up @@ -95,6 +98,9 @@
--tr-background: #54535a62;
--tr-background-secondary: #565161;

--pinned-background-color: #252424;
--pinned-border-color: #5f5555;

--cover-title-color: #dbdbdb;
--cover-meta-color: #d4d4d4;
--cover-tag-link-color: #d4d4d4;
Expand Down
5 changes: 5 additions & 0 deletions src/styles/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ $home-colors: (
'background': var(--home-background-color),
);

$pinned-colors: (
'background': var(--pinned-background-color),
'border': var(--pinned-border-color),
);

$cover-colors: (
'background': var(--cover-background-color),
'title': var(--cover-title-color),
Expand Down
55 changes: 55 additions & 0 deletions src/styles/components/pinned.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
@import
'../_variables';

.pinned {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 1em;
padding: 2em 1em 2em 1em;
border-radius: 0.5em;

@media (max-width: 1200px) {
grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 768px) {
grid-template-columns: 1fr;
}
}

.pinned-card {
background-color: map-get($pinned-colors, 'background');
border: 0.01em solid map-get($pinned-colors, 'border');
border-radius: 0.3em;
padding: 0.6em 1em 0.2em 1em;
display: flex;
flex-direction: column;
color: map-get($basic-colors, 'base');

&:hover {
background-color: map-get($home-colors, 'background');
}

p {
margin: 0;
}

.title {
font-style: italic;
font-size: medium;

font-size: 1em;
}

.description {
font-size: 0.7em;
margin-left: 0.3em;
}

.link {
display: flex;
justify-content: space-between;
font-size: 1em;
align-self: flex-end;
}
}

0 comments on commit ae21e91

Please sign in to comment.