From c83701ec586115c8fa6f5fc63aed35484f8b339c Mon Sep 17 00:00:00 2001 From: Jean-Philippe Sirois Date: Mon, 25 May 2020 23:23:46 -0400 Subject: [PATCH] ui(resources): tweak styling of resource list --- src/components/Link/index.tsx | 10 ++++--- src/components/ResourcesList/index.tsx | 10 +++---- src/components/ResourcesList/styles.tsx | 35 +++++++++---------------- 3 files changed, 25 insertions(+), 30 deletions(-) diff --git a/src/components/Link/index.tsx b/src/components/Link/index.tsx index 2564fc7..9d5d93d 100644 --- a/src/components/Link/index.tsx +++ b/src/components/Link/index.tsx @@ -5,13 +5,17 @@ interface ILinkProps { to: string } -export const Link: FC = ({ children, to }) => { +export const Link: FC = ({ children, to, ...props }) => { if (!to.match(/^(https?:\/\/)/)) { - return {children} + return ( + + {children} + + ) } return ( - + {children} ) diff --git a/src/components/ResourcesList/index.tsx b/src/components/ResourcesList/index.tsx index f8eae11..5f9c3cb 100644 --- a/src/components/ResourcesList/index.tsx +++ b/src/components/ResourcesList/index.tsx @@ -1,3 +1,4 @@ +import cx from "classnames" import { graphql, useStaticQuery } from "gatsby" import sort from "ramda/es/sort" import React, { FC, HTMLAttributes, memo, useMemo } from "react" @@ -34,10 +35,7 @@ function plantTree(item: IFileOrFolder, single?: boolean) { return ( - {cleanedUpPath.map((node) => ( - // TODO: use helper to format path - {humanize(node)} - ))} + {cleanedUpPath.map((node) => humanize(node)).join(" / ")} ) } @@ -61,7 +59,9 @@ const Language = memo( return ( {!single && {humanize(item.title)}} - {children.map((node) => plantTree(node))} + + {children.map((node) => plantTree(node))} + ) } diff --git a/src/components/ResourcesList/styles.tsx b/src/components/ResourcesList/styles.tsx index 7cffb67..ca63668 100644 --- a/src/components/ResourcesList/styles.tsx +++ b/src/components/ResourcesList/styles.tsx @@ -1,6 +1,6 @@ -import { Link } from "gatsby" import { transparentize } from "polished" import styled from "styled-components" +import { Link } from "../Link" export const ResourcesListWrapper = styled.div` box-sizing: border-box; @@ -14,6 +14,10 @@ export const Children = styled.div` flex-direction: column; align-items: flex-start; overflow: hidden; + + &.is-single { + padding-left: 0; + } ` export const Label = styled.div` @@ -65,7 +69,10 @@ export const TreeWrapper = styled.div` flex-direction: column; width: 100%; font-size: 16px; - margin: 32px 0; + + & + & { + margin-top: 32px; + } ${Children} { display: flex; @@ -77,27 +84,11 @@ export const TreeWrapper = styled.div` ` export const PageLink = styled(Link)` - display: block; - padding: 2px 0; - color: ${(props) => props.theme.sidebar.foreground}; - align-self: flex-start; - text-decoration: none; - border-bottom: 1px solid transparent; - - &:hover { - border-color: ${(props) => - transparentize(0.7, props.theme.sidebar.foreground)}; - } + font-weight: 400; + display: inline-block; + font-size: 18px; & + & { - margin-top: 4px; - } -` - -export const NodePart = styled.span` - & + &::before { - content: "/"; - opacity: 0.3; - margin: 0 4px; + margin-top: 8px; } `