Skip to content

Commit

Permalink
DEVPROD-11387: Remove CSS grid layout (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
sophstad authored Sep 19, 2024
1 parent b84a004 commit aec8832
Show file tree
Hide file tree
Showing 10 changed files with 227 additions and 201 deletions.
6 changes: 3 additions & 3 deletions apps/spruce/src/components/Content/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useAnalyticsAttributes } from "analytics";
import { Feedback } from "components/Feedback";
import { Header } from "components/Header";
import { FullPageLoad } from "components/Loading/FullPageLoad";
import { PageGrid } from "components/styles/Layout";
import { SiteLayout } from "components/styles/Layout";
import { TaskStatusIconLegend } from "components/TaskStatusIconLegend";
import WelcomeModal from "components/WelcomeModal";
import { CY_DISABLE_NEW_USER_WELCOME_MODAL } from "constants/cookies";
Expand Down Expand Up @@ -44,7 +44,7 @@ export const Layout: React.FC = () => {
}

return (
<PageGrid>
<SiteLayout>
<Header />
<Outlet />
{!shouldDisableForTest && !hasUsedSpruceBefore && (
Expand All @@ -58,7 +58,7 @@ export const Layout: React.FC = () => {
<TaskStatusIconLegend />
<Feedback />
</FloatingContent>
</PageGrid>
</SiteLayout>
);
};

Expand Down
4 changes: 3 additions & 1 deletion apps/spruce/src/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export const Header: React.FC = () => (
);

const StyledHeader = styled.header`
grid-area: header;
position: sticky;
top: 0;
width: 100%;
`;

const BannerContainer = styled.div`
Expand Down
32 changes: 21 additions & 11 deletions apps/spruce/src/components/styles/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,33 @@ import { size, fontSize } from "constants/tokens";

const { gray, red } = palette;

export const PageWrapper = styled.div`
grid-area: contents;
// Top-level layout for the entire site. Manages positioning of navbar.
export const SiteLayout = styled.div`
display: flex;
flex-flow: column;
height: 100vh;
`;

// Layout elements for pages with a LeafyGreen SideNav
export const SideNavPageWrapper = styled.div`
display: flex;
overflow: hidden;
height: 100%;
`;
export const SideNavPageContent = styled.div`
overflow-x: hidden;
overflow-y: scroll;
flex-grow: 1;
padding: ${size.m} ${size.l};
`;

export const PageGrid = styled.div`
display: grid;
grid-template-areas:
"header header"
"sidenav contents";
grid-template-columns: auto minmax(0, 1fr);
grid-template-rows: auto 1fr;
height: 100vh;
// Layout elements for non-LG SideNav pages
export const PageWrapper = styled.div`
height: 100%;
overflow-x: hidden;
overflow-y: scroll;
padding: ${size.m} ${size.l};
`;

export const PageLayout = styled.section<{ hasSider?: boolean }>`
display: flex;
flex: auto;
Expand Down
3 changes: 2 additions & 1 deletion apps/spruce/src/components/styles/SideNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import { zIndex, size } from "constants/tokens";
const { blue } = palette;

export const SideNav = styled(LGSideNav)`
grid-area: sidenav;
flex-shrink: 0;
flex-grow: 0;
z-index: ${zIndex.sideNav};
`;

Expand Down
8 changes: 6 additions & 2 deletions apps/spruce/src/components/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import {
InputLabel,
PageButtonRow,
PageContent,
PageGrid,
SiteLayout,
PageLayout,
PageSider,
SideNavPageContent,
SideNavPageWrapper,
PageTitle,
PageWrapper,
TableControlInnerRow,
Expand All @@ -28,14 +30,16 @@ export {
InputLabel,
PageButtonRow,
PageContent,
PageGrid,
SiteLayout,
PageLayout,
PageSider,
PageTitle,
PageWrapper,
SideNav,
SideNavGroup,
SideNavItem,
SideNavPageContent,
SideNavPageWrapper,
SiderCard,
StyledLink,
StyledRouterLink,
Expand Down
111 changes: 57 additions & 54 deletions apps/spruce/src/pages/distroSettings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
SideNav,
SideNavGroup,
SideNavItem,
PageWrapper,
SideNavPageContent,
SideNavPageWrapper,
} from "components/styles";
import { SideNavItemLink } from "components/styles/SideNav";
import { showImageVisibilityPage } from "constants/featureFlags";
Expand Down Expand Up @@ -64,63 +65,65 @@ const DistroSettings: React.FC = () => {

return (
<DistroSettingsProvider>
<SideNav aria-label="Distro Settings" widthOverride={250}>
<ButtonsContainer>
{/* @ts-expect-error: FIXME. This comment was added by an automated script. */}
<DistroSelect selectedDistro={distroId} />
<NewDistroButton />
</ButtonsContainer>
<SideNavGroup>
{Object.values(DistroSettingsTabRoutes).map((tab) => (
<SideNavItem
key={tab}
active={tab === currentTab}
as={Link}
data-cy={`navitem-${tab}`}
// @ts-expect-error: FIXME. This comment was added by an automated script.
to={getDistroSettingsRoute(distroId, tab)}
>
{getTabTitle(tab).title}
</SideNavItem>
))}
</SideNavGroup>
<SideNavGroup glyph={<Icon glyph="Link" />} header="Links">
<SideNavItemLink
data-cy="navitem-task-queue-link"
// @ts-expect-error: FIXME. This comment was added by an automated script.
to={getTaskQueueRoute(distroId)}
>
Task Queue
</SideNavItemLink>
{showImageVisibilityPage && (
<SideNavPageWrapper>
<SideNav aria-label="Distro Settings" widthOverride={250}>
<ButtonsContainer>
{/* @ts-expect-error: FIXME. This comment was added by an automated script. */}
<DistroSelect selectedDistro={distroId} />
<NewDistroButton />
</ButtonsContainer>
<SideNavGroup>
{Object.values(DistroSettingsTabRoutes).map((tab) => (
<SideNavItem
key={tab}
active={tab === currentTab}
as={Link}
data-cy={`navitem-${tab}`}
// @ts-expect-error: FIXME. This comment was added by an automated script.
to={getDistroSettingsRoute(distroId, tab)}
>
{getTabTitle(tab).title}
</SideNavItem>
))}
</SideNavGroup>
<SideNavGroup glyph={<Icon glyph="Link" />} header="Links">
<SideNavItemLink
data-cy="navitem-image-build-information-link"
to={getImageRoute(
data?.distro?.imageId ?? "",
ImageTabRoutes.BuildInformation,
)}
>
Image Build Information
</SideNavItemLink>
)}
{showImageVisibilityPage && (
<SideNavItemLink
data-cy="navitem-image-event-log-link"
to={getImageRoute(
data?.distro?.imageId ?? "",
ImageTabRoutes.EventLog,
)}
data-cy="navitem-task-queue-link"
// @ts-expect-error: FIXME. This comment was added by an automated script.
to={getTaskQueueRoute(distroId)}
>
Image Event Log
Task Queue
</SideNavItemLink>
{showImageVisibilityPage && (
<SideNavItemLink
data-cy="navitem-image-build-information-link"
to={getImageRoute(
data?.distro?.imageId ?? "",
ImageTabRoutes.BuildInformation,
)}
>
Image Build Information
</SideNavItemLink>
)}
{showImageVisibilityPage && (
<SideNavItemLink
data-cy="navitem-image-event-log-link"
to={getImageRoute(
data?.distro?.imageId ?? "",
ImageTabRoutes.EventLog,
)}
>
Image Event Log
</SideNavItemLink>
)}
</SideNavGroup>
</SideNav>
<SideNavPageContent data-cy="distro-settings-page">
{!loading && data?.distro && (
<DistroSettingsTabs distro={data.distro} />
)}
</SideNavGroup>
</SideNav>
<PageWrapper data-cy="distro-settings-page">
{!loading && data?.distro && (
<DistroSettingsTabs distro={data.distro} />
)}
</PageWrapper>
</SideNavPageContent>
</SideNavPageWrapper>
</DistroSettingsProvider>
);
};
Expand Down
11 changes: 6 additions & 5 deletions apps/spruce/src/pages/image/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
SideNav,
SideNavGroup,
SideNavItem,
PageWrapper,
SideNavPageContent,
SideNavPageWrapper,
} from "components/styles";
import { ImageTabRoutes, getImageRoute, slugs } from "constants/routes";
import { size } from "constants/tokens";
Expand Down Expand Up @@ -37,7 +38,7 @@ const Image: React.FC = () => {
}

return (
<>
<SideNavPageWrapper>
<SideNav aria-label="Image" widthOverride={250}>
<ButtonsContainer>
<ImageSelect selectedImage={selectedImage} />
Expand All @@ -56,10 +57,10 @@ const Image: React.FC = () => {
))}
</SideNavGroup>
</SideNav>
<PageWrapper>
<SideNavPageContent>
<ImageTabs currentTab={currentTab} imageId={selectedImage} />
</PageWrapper>
</>
</SideNavPageContent>
</SideNavPageWrapper>
);
};

Expand Down
11 changes: 6 additions & 5 deletions apps/spruce/src/pages/preferences/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
SideNav,
SideNavGroup,
SideNavItem,
PageWrapper,
SideNavPageContent,
SideNavPageWrapper,
} from "components/styles";
import {
PreferencesTabRoutes,
Expand All @@ -23,7 +24,7 @@ const Preferences: React.FC = () => {
const { sendEvent } = usePreferencesAnalytics();

return (
<>
<SideNavPageWrapper>
<SideNav aria-label="Preferences">
<SideNavGroup glyph={<Icon glyph="Settings" />} header="Preferences">
<SideNavItem
Expand Down Expand Up @@ -98,10 +99,10 @@ const Preferences: React.FC = () => {
</SideNavItem>
</SideNavGroup>
</SideNav>
<PageWrapper>
<SideNavPageContent>
<PreferencesTabs />
</PageWrapper>
</>
</SideNavPageContent>
</SideNavPageWrapper>
);
};

Expand Down
Loading

0 comments on commit aec8832

Please sign in to comment.