Skip to content

Commit

Permalink
✨ Add catlinez page containing all components
Browse files Browse the repository at this point in the history
  • Loading branch information
fre-ben committed Feb 14, 2021
1 parent b5e2fe6 commit dad0519
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 7 deletions.
4 changes: 4 additions & 0 deletions notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,7 @@ return test;
dRj7MBwlYafKn4RJFGHIM--anhE1w_bpXLYKo7hdZIKJW0eX

https://api.currentsapi.services/v1/latest-news?language=de&apiKey=dRj7MBwlYafKn4RJFGHIM--anhE1w_bpXLYKo7hdZIKJW0eX

## Todo

- Sport news rausfiltern
File renamed without changes.
22 changes: 22 additions & 0 deletions src/pages/catlinez/catlinez.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import "./catlinez.css";
import { displayHeader } from "../../components/header/header";
import { createElement } from "../../utils/createElement";
import { getRandomCat, getRandomHeadlineGerman } from "../../utils/api";
import { displayCat } from "../../components/cat/randomcat";
import { displayGermanHeadline } from "../../components/headline/headline";

export default { title: "Pages/Catlinez", parameters: { layout: "centered" } };

export const catlinez = (args, { loaded: { cat, headline } }) => {
return createElement("div", {
className: "catlinez__container",
childs: [displayHeader(), displayCat(cat), displayGermanHeadline(headline)],
});
};

catlinez.loaders = [
async () => ({
cat: await getRandomCat(),
headline: await getRandomHeadlineGerman(),
}),
];
11 changes: 11 additions & 0 deletions src/pages/catlinez/catlinez.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { displayHeader } from "../../components/header/header";
import { createElement } from "../../utils/createElement";
import { getRandomCat } from "../../utils/api";
import { displayCat } from "../../components/cat/randomcat";

export function buildCatlinez() {
return createElement("div", {
className: "app__container",
childs: [displayHeader()],
});
}
Empty file removed src/pages/welcome/welcome.html
Empty file.
6 changes: 0 additions & 6 deletions src/pages/welcome/welcome.stories.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function convertToText(headline: News): Headline {

export async function getRandomHeadlineGerman() {
const response = await fetch(
`https://api.currentsapi.services/v1/latest-news?language=de&apiKey=dRj7MBwlYafKn4RJFGHIM--anhE1w_bpXLYKo7hdZIKJW0eX`
`https://api.currentsapi.services/v1/latest-news?category=general&language=de&apiKey=dRj7MBwlYafKn4RJFGHIM--anhE1w_bpXLYKo7hdZIKJW0eX`
);
const result = (await response.json()) as News;
const headline = convertToText(result);
Expand Down

0 comments on commit dad0519

Please sign in to comment.