Skip to content
Merged
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
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2025 Gavin Garcia

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
73 changes: 7 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,69 +1,10 @@
# React + TypeScript + Vite
# SpeedReader

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
SpeedReader is a lightweight, open‑source speed‑reading web application built with **React** and **Vite**.
It runs entirely in your browser—no backend, no log‑ins, and no data leaves your device.

Currently, two official plugins are available:
- **Privacy‑first:** Text is never sent to any server.
- **Zero setup:** Just open the page, paste or type your text, and start reading.
- **Open source:** Licensed under MIT and welcoming contributions.

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:

```js
export default tseslint.config([
globalIgnores(["dist"]),
{
files: ["**/*.{ts,tsx}"],
extends: [
// Other configs...

// Remove tseslint.configs.recommended and replace with this
...tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
...tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
...tseslint.configs.stylisticTypeChecked,

// Other configs...
],
languageOptions: {
parserOptions: {
project: ["./tsconfig.node.json", "./tsconfig.app.json"],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
]);
```

You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:

```js
// eslint.config.js
import reactX from "eslint-plugin-react-x";
import reactDom from "eslint-plugin-react-dom";

export default tseslint.config([
globalIgnores(["dist"]),
{
files: ["**/*.{ts,tsx}"],
extends: [
// Other configs...
// Enable lint rules for React
reactX.configs["recommended-typescript"],
// Enable lint rules for React DOM
reactDom.configs.recommended,
],
languageOptions: {
parserOptions: {
project: ["./tsconfig.node.json", "./tsconfig.app.json"],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
]);
```
> Read faster without giving up your data.
21 changes: 20 additions & 1 deletion src/SpeedReader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,30 @@ export default function SpeedReader() {

/* words of current section */
const words = useMemo(() => {
// Helper to split hyphenated words as described
function splitHyphenatedWord(word: string): string[] {
if (!word.includes("-")) return [word];
const parts = word.split("-");
if (parts.length === 1) return [word];
const result: string[] = [];
for (let i = 0; i < parts.length; i++) {
if (i === 0) {
result.push(parts[i] + "-");
} else if (i === parts.length - 1) {
result.push("-" + parts[i]);
} else {
result.push("-" + parts[i] + "-");
}
}
return result;
}

return (
sections[current]
?.replaceAll(/[\r\n\t]+/g, " ")
.split(" ")
.filter(Boolean) ?? []
.filter(Boolean)
.flatMap(splitHyphenatedWord) ?? []
);
}, [sections, current]);

Expand Down
23 changes: 23 additions & 0 deletions src/components/PillButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export interface PillButtonProps {
onClick: (e: React.MouseEvent<HTMLButtonElement>) => void;
ariaLabel: string;
children: React.ReactNode;
className?: string;
}
export function PillButton({
onClick,
ariaLabel,
children,
className = "",
}: PillButtonProps) {
return (
<button
type="button"
className={`absolute w-8 h-8 bg-white border rounded-full shadow flex items-center justify-center text-gray-400 hover:text-blue-500 focus:outline-none ${className}`}
onClick={onClick}
aria-label={ariaLabel}
>
{children}
</button>
);
}
60 changes: 60 additions & 0 deletions src/components/PillButtonContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import clsx from "clsx";
import { Children } from "react";
import type { ReactNode, CSSProperties } from "react";

export type Corner = "top-right" | "top-left" | "bottom-right" | "bottom-left";

interface PillButtonContainerProps {
children: ReactNode;
corner?: Corner;
className?: string;
style?: CSSProperties;
}

export const PillButtonContainer = ({
children,
corner = "top-right",
className,
style,
}: PillButtonContainerProps) => {
const step = 35 + 8;

const toOffset = (row: number, col: number): CSSProperties => {
const y = row * step;
const x = col * step;

switch (corner) {
case "top-left":
return { top: y, left: x };
case "bottom-right":
return { bottom: y, right: x };
case "bottom-left":
return { bottom: y, left: x };
case "top-right":
default:
return { top: y, right: x };
}
};

const wrapped = Children.toArray(children).map((child, i) => {
const [row, col] = [0, i];
return (
<div key={i} style={{ position: "absolute", ...toOffset(row, col) }}>
{child}
</div>
);
});

const cornerPos = {
"top-right": "top-0 right-0 -translate-x-10 -translate-y-5",
"top-left": "top-0 left-0 -translate-x-1/2 -translate-y-1/2",
"bottom-right": "bottom-0 right-0 translate-x-1/2 translate-y-1/2",
"bottom-left": "bottom-0 left-0 -translate-x-1/2 translate-y-1/2",
}[corner];

return (
<div className={clsx("absolute", cornerPos, className)} style={style}>
{wrapped}
</div>
);
};
Loading