Skip to content

Commit b408deb

Browse files
committed
make list responsive
1 parent dcb582c commit b408deb

File tree

4 files changed

+39
-8
lines changed

4 files changed

+39
-8
lines changed

src/components/CrowdFund/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const CrowdFundList: FunctionComponent<Props> = ({ hideHeader = false, in
2525
<TerminalIcon />
2626
<span className="inline-block ml-2">Crowdfunding Campaigns</span>
2727
</h1>
28-
<CampaignList />
28+
<CampaignList inline={inline} />
2929
</div>
3030
</div>
3131
);

src/components/CrowdFund/list.tsx

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext } from 'react';
1+
import React, { useContext, FunctionComponent } from 'react';
22
import Link from 'next/link';
33
import useSWR from 'swr';
44

@@ -10,8 +10,13 @@ import { CampaignEmptyState } from '../empty-states/campaign';
1010
import fetch from '../../lib/fetch';
1111
import { ShareContext } from '../../services/share';
1212
import { truncateString } from '../../utils';
13+
import clsx from 'clsx';
1314

14-
export const CampaignList = () => {
15+
interface Props {
16+
inline?: boolean;
17+
}
18+
19+
export const CampaignList: FunctionComponent<Props> = ({ inline = false }) => {
1520
const { isOpen, openShareDialog } = useContext(ShareContext);
1621
const { data, error } = useSWR<Campaign[]>('/api/campaigns', fetch);
1722

@@ -39,15 +44,15 @@ export const CampaignList = () => {
3944
<ul className="w-full md:flex md:flex-wrap">
4045
{data.map(item => {
4146
return (
42-
<li key={item.id} className="mx-0 my-4 md:mx-4">
47+
<li key={item.id} className={clsx('mx-0 my-4 md:mx-4', inline && 'inline')}>
4348
<Link href="/crowdfund/[slug]" as={`/crowdfund/${item.slug}`}>
44-
<a className="block p-4 px-6 bg-white shadow-lg rounded-lg" style={{ maxWidth: 420 }}>
49+
<a className="block p-4 px-6 bg-white shadow-lg rounded-lg list-item">
4550
<h3 className="text-xl mb-1 font-medium text-gray-800">
4651
<span className="hidden md:block">{truncateString(item.title, 30)}</span>
4752
<span className="md:hidden">{item.title}</span>
4853
</h3>
49-
<p className="text-sm mb-4 text-gray-700">
50-
<span className="hidden md:block">{truncateString(item.short_description, 45)}</span>
54+
<p className="text-sm mb-4 text-gray-700 md:h-8">
55+
<span className="hidden md:block">{truncateString(item.short_description, 91)}</span>
5156
<span className="md:hidden">{item.short_description}</span>
5257
</p>
5358
<CampaignProgress campaign={item} />
@@ -66,6 +71,26 @@ export const CampaignList = () => {
6671
</div>
6772
</a>
6873
</Link>
74+
<style jsx>{`
75+
li {
76+
width: calc(50% - 32px);
77+
}
78+
@media (max-width: 1224px) {
79+
li.inline {
80+
width: 80%;
81+
}
82+
}
83+
@media (max-width: 1000px) {
84+
li.inline {
85+
width: 100%;
86+
}
87+
}
88+
@media (max-width: 900px) {
89+
li {
90+
width: 100%;
91+
}
92+
}
93+
`}</style>
6994
</li>
7095
);
7196
})}

src/components/Home/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { EmojiIcon } from '../Icons/common';
55

66
export const HomeContent = () => {
77
return (
8-
<div className="py-4 pb-6 pb-20 md:pb-0">
8+
<div className="py-4 pb-6 pb-20 md:pb-0 xs:max-w-xs sm:xs-auto sm:max-w-md sm:mx-auto">
99
<p className="px-6 mb-4 md:mb-6 text-sm md:text-base font-medium leading-relaxed">
1010
<span className="text-base font-bold text-purple-700">Coderplex Foundation</span> is a registered non-profit
1111
organization that is working towards improving the state of tech in India.

src/styles/index.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ body {
4141
.markdown h3 {
4242
@apply leading-tight text-lg font-bold text-black mt-8 -mb-2;
4343
}
44+
.markdown p {
45+
@apply text-sm font-medium leading-relaxed;
46+
@media (min-width: 768px) {
47+
@apply text-base;
48+
}
49+
}
4450
.markdown code {
4551
@apply font-mono text-sm inline bg-gray-500 px-1;
4652
}

0 commit comments

Comments
 (0)