Skip to content

Commit

Permalink
Projects Page Finer Details (#4988)
Browse files Browse the repository at this point in the history
* chaneg card size

* fx grid

* fix grid

* fix gradient

* subtitle color

* match designs

* move new project buttons

* fix dropdown alignment

* dropdown triggers are grey when menu is open

* adressing comments

* react useCallback
  • Loading branch information
lankaukk authored Mar 5, 2024
1 parent 62a1817 commit 44c39a4
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 53 deletions.
8 changes: 1 addition & 7 deletions utopia-remix/app/components/projectActionContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,7 @@ export const ProjectContextMenu = React.memo(({ project }: { project: ProjectWit

return (
<DropdownMenu.Portal>
<DropdownMenu.Content
className={contextMenuDropdown()}
style={{
right: 75,
}}
sideOffset={5}
>
<DropdownMenu.Content className={contextMenuDropdown()} align='end' sideOffset={5}>
{menuEntries.map((entry, index) => {
if (entry === 'separator') {
return (
Expand Down
8 changes: 1 addition & 7 deletions utopia-remix/app/components/sortProjectsContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@ export const SortingContextMenu = React.memo(() => {

return (
<DropdownMenu.Portal>
<DropdownMenu.Content
className={contextMenuDropdown()}
style={{
right: 60,
}}
sideOffset={5}
>
<DropdownMenu.Content className={contextMenuDropdown()} sideOffset={5} align='end'>
<DropdownMenu.Label style={{ color: 'grey', padding: 5 }}>Sort by</DropdownMenu.Label>
<DropdownMenu.CheckboxItem
className={contextMenuItem()}
Expand Down
70 changes: 33 additions & 37 deletions utopia-remix/app/routes/projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { OperationWithKey, useProjectsStore } from '../store'
import { button } from '../styles/button.css'
import { newProjectButton } from '../styles/newProjectButton.css'
import { projectCategoryButton, userName } from '../styles/sidebarComponents.css'
import { projectCards, projectRows } from '../styles/projects.css'
import { sprinkles } from '../styles/sprinkles.css'
import {
Collaborator,
Expand Down Expand Up @@ -249,7 +250,6 @@ const Sidebar = React.memo(({ user }: { user: UserDetails }) => {
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
padding: '0 14px',
}}
placeholder='Search…'
/>
Expand Down Expand Up @@ -304,7 +304,7 @@ const TopActionBar = React.memo(() => {
id: 'createProject',
title: '+ Blank Project',
onClick: () => window.open(projectEditorLink(null), '_blank'),
color: 'orange',
color: 'primary',
},
// {
// title: '+ Project On GitHub',
Expand Down Expand Up @@ -334,6 +334,7 @@ const TopActionBar = React.memo(() => {
height: 60,
flex: 0,
display: 'flex',
justifyContent: 'flex-end',
flexDirection: 'row',
gap: 15,
}}
Expand Down Expand Up @@ -373,6 +374,11 @@ const ProjectsHeader = React.memo(({ projects }: { projects: ProjectWithoutConte
}
}

const [sortMenuOpen, setSortMenuOpen] = React.useState(false)
const handleSortMenuOpenChange = React.useCallback(() => {
setSortMenuOpen((prevSortMenuOpen) => !prevSortMenuOpen)
}, [])

return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 5 }}>
<div
Expand Down Expand Up @@ -434,13 +440,14 @@ const ProjectsHeader = React.memo(({ projects }: { projects: ProjectWithoutConte
<div style={{ display: 'flex', flexDirection: 'row', gap: 10 }}>
{when(
projects.length > 1,
<DropdownMenuRoot>
<DropdownMenuRoot onOpenChange={handleSortMenuOpenChange}>
<DropdownMenuTrigger asChild>
<div
className={button()}
style={{
justifyContent: 'flex-end',
gap: 10,
background: sortMenuOpen ? '#a4a4a430' : 'inherit',
}}
>
<div>{convertToTitleCase(sortCriteria)} </div>
Expand Down Expand Up @@ -544,14 +551,7 @@ const Projects = React.memo(
<>
{when(
projects.length > 0 && !gridView,
<div
style={{
flexGrow: 1,
overflowY: 'scroll',
scrollbarColor: 'lightgrey transparent',
gap: 10,
}}
>
<div className={projectRows()}>
{projects.map((project) => (
<ProjectRow
key={project.proj_id}
Expand All @@ -565,18 +565,7 @@ const Projects = React.memo(
)}
{when(
projects.length > 0 && gridView,
<div
style={{
display: 'flex',
flexWrap: 'wrap',
alignContent: 'flex-start',
gap: MarginSize,
flexGrow: 1,
flexDirection: 'row',
overflowY: 'scroll',
scrollbarColor: 'lightgrey transparent',
}}
>
<div className={projectCards()}>
{projects.map((project) => (
<ProjectCard
key={project.proj_id}
Expand Down Expand Up @@ -643,11 +632,10 @@ const ProjectCard = React.memo(
return (
<div
style={{
height: 200,
width: 300,
height: 220,
display: 'flex',
flexDirection: 'column',
gap: 5,
gap: 10,
filter: activeOperations.length > 0 ? 'grayscale(1)' : undefined,
}}
>
Expand All @@ -656,9 +644,9 @@ const ProjectCard = React.memo(
border: selected ? '2px solid #0075F9' : '2px solid transparent',
borderRadius: 10,
overflow: 'hidden',
height: 180,
width: '100%',
background: 'linear-gradient(rgba(77, 255, 223, 0.4), rgba(255,250,220,.8))',
height: 170,
width: 280,
background: 'linear-gradient(#a4a4a4, #a4a4a410)',
backgroundAttachment: 'local',
backgroundRepeat: 'no-repeat',
position: 'relative',
Expand Down Expand Up @@ -723,9 +711,9 @@ const ProjectCard = React.memo(
alignItems: 'center',
}}
>
<div style={{ display: 'flex', flexDirection: 'column', padding: 10, gap: 5, flex: 1 }}>
<div style={{ fontWeight: 600 }}>{projectTitle}</div>
<div>{moment(project.modified_at).fromNow()}</div>
<div style={{ display: 'flex', flexDirection: 'column', padding: 10, gap: 10, flex: 1 }}>
<div style={{ fontWeight: 500 }}>{project.title}</div>
<div style={{ opacity: 0.5 }}>{moment(project.modified_at).fromNow()}</div>
</div>
<ProjectCardActions project={project} />
</div>
Expand Down Expand Up @@ -783,7 +771,7 @@ const ProjectRow = React.memo(
overflow: 'hidden',
height: 40,
width: 70,
background: 'linear-gradient(rgba(77, 255, 223, 0.4), rgba(255,250,220,.8))',
background: 'linear-gradient(#a4a4a4, #a4a4a410)',
backgroundAttachment: 'local',
backgroundRepeat: 'no-repeat',
position: 'relative',
Expand All @@ -794,12 +782,12 @@ const ProjectRow = React.memo(
flexGrow: 1,
minWidth: 180,
maxWidth: 380,
fontWeight: 600,
fontWeight: 500,
}}
>
{project.title}
</div>
<div style={{ width: 220 }}>{moment(project.modified_at).fromNow()}</div>
<div style={{ width: 220, opacity: 0.5 }}>{moment(project.modified_at).fromNow()}</div>
<div
style={{
maxWidth: 480,
Expand Down Expand Up @@ -852,11 +840,19 @@ const ProjectRow = React.memo(
ProjectRow.displayName = 'ProjectRow'

const ProjectCardActions = React.memo(({ project }: { project: ProjectWithoutContent }) => {
const [sortMenuOpen, setSortMenuOpen] = React.useState(false)
const handleSortMenuOpenChange = React.useCallback(() => {
setSortMenuOpen((prevSortMenuOpen) => !prevSortMenuOpen)
}, [])

return (
<div style={{ display: 'flex', alignItems: 'center', gap: 5 }}>
<DropdownMenuRoot>
<DropdownMenuRoot onOpenChange={handleSortMenuOpenChange}>
<DropdownMenuTrigger asChild>
<DotsHorizontalIcon className={button()} />
<DotsHorizontalIcon
className={button()}
style={{ background: sortMenuOpen ? '#a4a4a430' : 'inherit' }}
/>
</DropdownMenuTrigger>
<ProjectContextMenu project={project} />
</DropdownMenuRoot>
Expand Down
4 changes: 3 additions & 1 deletion utopia-remix/app/styles/newProjectButton.css.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { recipe } from '@vanilla-extract/recipes'
import { sprinkles } from './sprinkles.css'
import { sprinkles, colors } from './sprinkles.css'

export const newProjectButton = recipe({
base: [
Expand All @@ -14,6 +14,7 @@ export const newProjectButton = recipe({
alignItems: 'center',
gap: 10,
fontSize: 16,
fontWeight: 500,
color: 'white',
height: 40,
opacity: 1,
Expand All @@ -30,6 +31,7 @@ export const newProjectButton = recipe({
purple: { background: '#9643FF' },
blue: { background: '#3992FF' },
green: { background: '#96BF48' },
primary: { background: colors.primary}
},

size: {
Expand Down
29 changes: 29 additions & 0 deletions utopia-remix/app/styles/projects.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { recipe } from '@vanilla-extract/recipes'
import { colors, sprinkles } from './sprinkles.css'

export const projectCards = recipe({
base: [
{
flexGrow: 1,
overflow: 'hidden scroll',
scrollbarColor: 'lightgrey transparent',
display: 'grid',
gridTemplateColumns: 'repeat(auto-fill, 280px)',
justifyContent: 'space-between',
alignContent: 'flex-start',
gridGap: '60px 40px',
paddingRight: 30,
},
],
})

export const projectRows = recipe({
base: [
{
flexGrow: 1,
overflowY: 'scroll',
scrollbarColor: 'lightgrey transparent',
gap: 10,
},
],
})
4 changes: 3 additions & 1 deletion utopia-remix/app/styles/sidebarComponents.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ export const projectCategoryButton = recipe({
display: 'flex',
alignItems: 'center',
gap: 10,
padding: '0 14px',
padding: '3px 14px',
height: 30,
fontWeight: 600,
fontSize: '12px',
color: 'gray', //fix me to be theme responsive
},
],
Expand Down

0 comments on commit 44c39a4

Please sign in to comment.