Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/components/ReadingPanel/ReadingPanel.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Button.stories.ts|tsx

import type { Meta, StoryObj } from "@storybook/react";
import { ButtonTypes, PanelDirections } from "../../constants";

import { ReadingPanel } from "./ReadingPanel";

Expand Down Expand Up @@ -48,7 +49,7 @@ export const Vertical: Story = {
...ReadingPanelTemplate,
args: {
settings: {
direction: "vertical",
direction: PanelDirections.,
},
},
};
Expand All @@ -58,7 +59,7 @@ export const Partial: Story = {
args: {
settings: {
startOpen: true,
showButtons: ["increase_font_size", "change_colors"],
showButtons: [ButtonTypes.INCREASE_FONT_SIZE, ButtonTypes.CHANGE_COLORS],
},
},
};
3 changes: 2 additions & 1 deletion src/components/ReadingPanel/ReadingPanel.styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import styled from "styled-components";
import { PanelDirection } from "./settings/settings.types";
import { PanelDirections } from "../../constants";

export const PanelButton = styled.button`
height: 35px;
Expand All @@ -17,7 +18,7 @@ export const PanelButton = styled.button`
export const Container = styled.div<{ direction?: PanelDirection }>`
display: flex;
flex-direction: ${(props) =>
props.direction === "vertical" ? "column" : "row"};
props.direction === PanelDirections.VERTICAL ? "column" : "row"};
align-items: center;
background: white;
padding: 5px 2px;
Expand Down
15 changes: 8 additions & 7 deletions src/components/ReadingPanel/ReadingPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { increaseLetterSpacing } from "./letter-spacing/increase-letter-spacing.
import { decreaseLineHeight } from "./line-height/decrease-line-height.util";
import { increaseLineHeight } from "./line-height/increase-line-height.util";
import { Settings, defaultSettings } from "./settings/settings.types";
import { ButtonTypes } from "../../constants";

interface Props {
targetClass?: string;
Expand Down Expand Up @@ -162,37 +163,37 @@ export function ReadingPanel({

{isOpen && (
<>
{showButtons.includes("increase_font_size") && (
{showButtons.includes(ButtonTypes.INCREASE_FONT_SIZE) && (
<PanelButton onClick={handleFontIncrease}>
<MdTextIncrease></MdTextIncrease>
</PanelButton>
)}
{showButtons.includes("decrease_font_size") && (
{showButtons.includes(ButtonTypes.DECREASE_FONT_SIZE) && (
<PanelButton onClick={handleFontDecrease}>
<MdTextDecrease></MdTextDecrease>
</PanelButton>
)}
{showButtons.includes("increase_line_height") && (
{showButtons.includes(ButtonTypes.INCREASE_LINE_HEIGHT) && (
<PanelButton onClick={handleLineHeightIncrease}>
<AiOutlineMenu></AiOutlineMenu>
</PanelButton>
)}
{showButtons.includes("decrease_line_height") && (
{showButtons.includes(ButtonTypes.DECREASE_LINE_HEIGHT) && (
<PanelButton onClick={handleLineHeightDecrease}>
<IoMenuOutline></IoMenuOutline>
</PanelButton>
)}
{showButtons.includes("change_colors") && (
{showButtons.includes(ButtonTypes.CHANGE_COLORS) && (
<PanelButton onClick={handleColorChange}>
<VscColorMode></VscColorMode>
</PanelButton>
)}
{showButtons.includes("increase_letter_spacing") && (
{showButtons.includes(ButtonTypes.INCREASE_LETTER_SPACING) && (
<PanelButton>
<FaExpandAlt onClick={handleLetterSpacingIncrease}></FaExpandAlt>
</PanelButton>
)}
{showButtons.includes("decrease_letter_spacing") && (
{showButtons.includes(ButtonTypes.DECREASE_LETTER_SPACING) && (
<PanelButton onClick={handleLetterSpacingDecrease}>
<ImShrink2></ImShrink2>
</PanelButton>
Expand Down
8 changes: 0 additions & 8 deletions src/components/ReadingPanel/settings/change-settings.util.ts
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this file deleted?

Copy link
Author

@eylonshm eylonshm Aug 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there's no actual use of it's only function @nitzano.

This file was deleted.

26 changes: 7 additions & 19 deletions src/components/ReadingPanel/settings/settings.types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ButtonTypes, PanelDirections } from "../../../constants";

export interface ColorSettings {
bgLightColor: string;
fgLightColor: string;
Expand All @@ -14,16 +16,10 @@ export const defaultColorSettings: ColorSettings = {

export type Theme = "light" | "dark";

export type PanelDirection = "horizontal" | "vertical";
export type PanelDirection =
(typeof PanelDirections)[keyof typeof PanelDirections];

export type ButtonType =
| "change_colors"
| "decrease_font_size"
| "decrease_letter_spacing"
| "decrease_line_height"
| "increase_font_size"
| "increase_letter_spacing"
| "increase_line_height";
export type ButtonType = (typeof ButtonTypes)[keyof typeof ButtonTypes];

export interface Settings {
colorSettings: ColorSettings;
Expand Down Expand Up @@ -53,14 +49,6 @@ export const defaultSettings: Settings = {
lineHeightsStep: 1,
lineHeightUnits: "px",
startOpen: false,
direction: "horizontal",
showButtons: [
"increase_font_size",
"decrease_font_size",
"increase_line_height",
"decrease_line_height",
"change_colors",
"increase_letter_spacing",
"decrease_letter_spacing",
],
direction: PanelDirections.HORIZONTAL,
showButtons: Object.values(ButtonTypes),
};
14 changes: 14 additions & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export const ButtonTypes = {
INCREASE_FONT_SIZE: "increase_font_size",
DECREASE_FONT_SIZE: "decrease_font_size",
INCREASE_LINE_HEIGHT: "increase_line_height",
DECREASE_LINE_HEIGHT: "decrease_line_height",
CHANGE_COLORS: "change_colors",
INCREASE_LETTER_SPACING: "increase_letter_spacing",
DECREASE_LETTER_SPACING: "decrease_letter_spacing",
};

export const PanelDirections = {
HORIZONTAL: "horizontal",
VERTICAL: "vertical",
};