Skip to content

Commit

Permalink
Fix mobile CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
pramodsum committed Mar 31, 2020
1 parent c72fc0e commit f6e7b96
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/components/ItemList/ItemList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import "./RecipeList.css";
import RecipeCard from "../RecipeCard/RecipeCard";
import { Recipe } from "../../utils/types";

const RecipeList: React.FC<{ items: Array<Recipe> }> = ({ items }) => {
const RecipeList: React.FC<{ recipes: Array<Recipe> }> = ({ recipes }) => {
return (
<List className="items-list">
{items.map(recipe => (
<List className="recipes-list">
{recipes.map(recipe => (
<RecipeCard recipe={recipe} />
))}
</List>
Expand Down
7 changes: 7 additions & 0 deletions src/components/RecipeCard/RecipeCard.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
margin: 10px;
}

@media only screen and (max-width: 600px) {
.recipe-card {
width: 100%;
max-width: 300px;
}
}

.recipe-card:hover {
background: lightgreen;
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/RecipeList/RecipeList.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.items-list {
.recipes-list {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
6 changes: 3 additions & 3 deletions src/components/RecipeList/RecipeList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import "./RecipeList.css";
import RecipeCard from "../RecipeCard/RecipeCard";
import { Recipe } from "../../utils/types";

const RecipeList: React.FC<{ items: Array<Recipe> }> = ({ items }) => {
const RecipeList: React.FC<{ recipes: Array<Recipe> }> = ({ recipes }) => {
return (
<List className="items-list">
{items.map(recipe => (
<List className="recipes-list">
{recipes.map(recipe => (
<RecipeCard recipe={recipe} />
))}
</List>
Expand Down
4 changes: 2 additions & 2 deletions src/routes/Homepage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Recipe } from "../utils/types";
import { TACO_API_BASE } from "../utils/globals";

const Homepage: React.FC = () => {
const [items, setItem] = React.useState<Array<Recipe>>([]);
const [recipes, setItem] = React.useState<Array<Recipe>>([]);

React.useEffect(() => {
fetch(`${TACO_API_BASE}/toppings`)
Expand All @@ -18,7 +18,7 @@ const Homepage: React.FC = () => {

return (
<Layout>
<RecipeList items={items} />
<RecipeList recipes={recipes} />
</Layout>
);
};
Expand Down

0 comments on commit f6e7b96

Please sign in to comment.