Skip to content

Commit f3c9f85

Browse files
committed
Refactor PillLabel component usage and improve workspace card layout
1 parent 8fe7943 commit f3c9f85

File tree

2 files changed

+48
-22
lines changed

2 files changed

+48
-22
lines changed

components/dashboard/src/components/PillLabel.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* See License.AGPL.txt in the project root for license information.
55
*/
66

7+
import { cn } from "@podkit/lib/cn";
8+
79
export type PillType = "info" | "warn" | "success" | "neutral";
810

911
const PillClsMap: Record<PillType, string> = {
@@ -27,6 +29,6 @@ const PillClsMap: Record<PillType, string> = {
2729
*/
2830
export default function PillLabel(props: { children?: React.ReactNode; type?: PillType; className?: string }) {
2931
const type = props.type || "info";
30-
const style = `px-3 py-0.5 text-xs uppercase rounded-xl font-semibold ${PillClsMap[type]} ${props.className}`;
31-
return <span className={style}>{props.children}</span>;
32+
const className = cn(`px-3 py-0.5 text-xs uppercase rounded-xl font-semibold ${PillClsMap[type]}`, props.className);
33+
return <span className={className}>{props.children}</span>;
3234
}

components/dashboard/src/workspaces/Workspaces.tsx

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { useSuggestedRepositories } from "../data/git-providers/suggested-reposi
3636
import { useUserLoader } from "../hooks/use-user-loader";
3737
import { cn } from "@podkit/lib/cn";
3838
import { useInstallationConfiguration } from "../data/installation/default-workspace-image-query";
39+
import PillLabel from "../components/PillLabel";
3940

4041
const WorkspacesPage: FunctionComponent = () => {
4142
const [limit, setLimit] = useState(50);
@@ -146,20 +147,21 @@ const WorkspacesPage: FunctionComponent = () => {
146147
Getting started
147148
</Subheading>
148149

149-
<div className="flex flex-wrap gap-5 lg:px-28 px-4">
150+
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5 lg:px-28 px-4">
150151
<Card onClick={() => setVideoModalVisible(true)}>
151152
<GraduationCap className="flex-shrink-0" size={24} />
152-
<div>
153+
<div className="min-w-0">
153154
<CardTitle>Learn how Gitpod works</CardTitle>
154155
<CardDescription>
155-
Weve put together resources for you to get the most our of Gitpod.
156+
We've put together resources for you to get the most our of Gitpod.
156157
</CardDescription>
157158
</div>
158159
</Card>
160+
159161
{orgSettings?.onboardingSettings?.internalLink ? (
160162
<Card href={orgSettings.onboardingSettings.internalLink} isLinkExternal>
161163
<Building className="flex-shrink-0" size={24} />
162-
<div>
164+
<div className="min-w-0">
163165
<CardTitle>Learn more about Gitpod at {org?.name}</CardTitle>
164166
<CardDescription>
165167
Read through the internal Gitpod landing page of your organization.
@@ -169,17 +171,18 @@ const WorkspacesPage: FunctionComponent = () => {
169171
) : (
170172
<Card href={"/new?showExamples=true"}>
171173
<Code className="flex-shrink-0" size={24} />
172-
<div>
174+
<div className="min-w-0">
173175
<CardTitle>Open a sample repository</CardTitle>
174176
<CardDescription>
175177
Explore a sample repository to quickly experience Gitpod.
176178
</CardDescription>
177179
</div>
178180
</Card>
179181
)}
182+
180183
<Card href="https://www.gitpod.io/docs/introduction" isLinkExternal>
181184
<Book className="flex-shrink-0" size={24} />
182-
<div>
185+
<div className="min-w-0">
183186
<CardTitle>Visit the docs</CardTitle>
184187
<CardDescription>
185188
We have extensive documentation to help if you get stuck.
@@ -194,15 +197,36 @@ const WorkspacesPage: FunctionComponent = () => {
194197
Suggested
195198
</Subheading>
196199

197-
<div className="flex flex-wrap gap-5 lg:px-28 px-4">
198-
{recentRepos.map((repo) => (
199-
<Card key={repo.url} href={`/new#${repo.url}`} className="border-[#D79A45] border">
200-
<div>
201-
<CardTitle>{repo.configurationName || repo.repoName}</CardTitle>
202-
<CardDescription>{repo.url}</CardDescription>
203-
</div>
204-
</Card>
205-
))}
200+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 lg:px-28 px-4">
201+
{[
202+
...recentRepos,
203+
// todo: add org-selected repos
204+
]
205+
.slice(0, 3)
206+
.map((repo) => (
207+
<Card
208+
key={repo.url}
209+
href={`/new#${repo.url}`}
210+
className="border-[#D79A45] border hover:bg-pk-surface-tertiary transition-colors w-full"
211+
>
212+
<div className="min-w-0 w-full space-y-1.5">
213+
<CardTitle className="flex flex-row items-center gap-2 w-full">
214+
<span className="truncate block min-w-0 text-base">
215+
{repo.configurationName || repo.repoName}
216+
</span>
217+
<PillLabel
218+
className="capitalize bg-kumquat-light shrink-0 text-sm"
219+
type="warn"
220+
>
221+
Recommended
222+
</PillLabel>
223+
</CardTitle>
224+
<CardDescription className="truncate text-sm opacity-75">
225+
{repo.url}
226+
</CardDescription>
227+
</div>
228+
</Card>
229+
))}
206230
</div>
207231
</>
208232
)}
@@ -376,11 +400,11 @@ const WorkspacesPage: FunctionComponent = () => {
376400

377401
export default WorkspacesPage;
378402

379-
const CardTitle = ({ children }: { children: React.ReactNode }) => {
380-
return <span className="text-lg font-semibold text-pk-content-primary">{children}</span>;
403+
const CardTitle = ({ children, className }: { className?: string; children: React.ReactNode }) => {
404+
return <span className={cn("text-lg font-semibold text-pk-content-primary", className)}>{children}</span>;
381405
};
382-
const CardDescription = ({ children }: { children: React.ReactNode }) => {
383-
return <p className="text-pk-content-secondary">{children}</p>;
406+
const CardDescription = ({ children, className }: { className?: string; children: React.ReactNode }) => {
407+
return <p className={cn("text-pk-content-secondary", className)}>{children}</p>;
384408
};
385409
type CardProps = {
386410
children: React.ReactNode;
@@ -391,7 +415,7 @@ type CardProps = {
391415
};
392416
const Card = ({ children, href, isLinkExternal, className: classNameFromProps, onClick }: CardProps) => {
393417
const className = cn(
394-
"bg-pk-surface-secondary flex gap-3 py-4 px-5 flex-grow basis-[300px] sm:basis-[45%] lg:basis-[30%] rounded-xl max-w-[400px] text-left",
418+
"bg-pk-surface-secondary flex gap-3 py-4 px-5 rounded-xl text-left w-full h-full",
395419
classNameFromProps,
396420
);
397421

0 commit comments

Comments
 (0)