Skip to content

Commit

Permalink
export divider width via variable
Browse files Browse the repository at this point in the history
  • Loading branch information
agneym committed Dec 18, 2019
1 parent 825543d commit ccd45a0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
13 changes: 7 additions & 6 deletions playground/src/Draggable/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import React, { FC, ReactNode, useRef } from "react";
import styled from "styled-components";
import React, { FC, ReactNode, useRef, useContext } from "react";
import styled, { ThemeContext } from "styled-components";

import useDrag from "./useDrag";

const Container = styled.div`
display: flex;
align-items: stretch;
`;

const DIVIDER_WIDTH = 3;

const Divider = styled.div`
width: ${DIVIDER_WIDTH}px;
width: ${props => props.theme.divider.width}px;
cursor: col-resize;
background-color: ${props => props.theme.divider.background};
`;

interface IProps {
Expand All @@ -23,11 +23,12 @@ interface IProps {
const Draggable: FC<IProps> = ({ className = "", leftChild, rightChild }) => {
const containerRef = useRef<HTMLDivElement>(null);
const dividerRef = useRef<HTMLDivElement>(null);
const themeContext = useContext(ThemeContext);

const { leftWidth, rightWidth } = useDrag({
containerRef,
dividerRef,
dividerWidth: DIVIDER_WIDTH,
dividerWidth: themeContext.divider.width,
});

return (
Expand Down
4 changes: 1 addition & 3 deletions playground/src/Editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import {
StyledTabPanel,
} from "../TabStyles";

const TabContainer = styled(StyledTabs)`
border-right: 0.05em solid rgba(0, 0, 0, 0.2);
`;
const TabContainer = styled(StyledTabs)``;

interface IProps {
width: number;
Expand Down
4 changes: 4 additions & 0 deletions playground/src/utils/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ const theme: DefaultTheme = {
console: {
background: "rgba(0, 0, 0, 1)",
},
divider: {
width: 2,
background: " #202020",
},
tabs: {
tabHeader: {
borderBottom: "0.1em solid rgba(0, 0, 0, 0.1)",
Expand Down

0 comments on commit ccd45a0

Please sign in to comment.