Skip to content

Commit

Permalink
fix: cursor state after 'pointerup' event
Browse files Browse the repository at this point in the history
  • Loading branch information
yamogoo committed Jul 16, 2024
1 parent 599310d commit 3046ae8
Show file tree
Hide file tree
Showing 24 changed files with 202 additions and 96 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

| | Package name | Installation | Example | Version / License |
| --------------------------------------- | ------------------------------------------------------------------------ | ---------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| ![image](/shared/images/vue-logo.svg) | [Vue3 Resize Bounding](/packages/vue/vue3-resize-bounding/README.md) | `npm i vue3-resize-bounding` | [stackblitz](https://stackblitz.com/edit/vue3-resize-bounding-example?file=src%2FApp.vue), [github](https://github.com/yamogoo/resize-bounding/blob/v2.0.2/packages/vue/playground/vite-app/src/components/InteractiveGrid.vue) | ![Version](https://img.shields.io/badge/version-2.0.2-green) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](./LICENSE) |
| ![image](/shared/images/react-logo.svg) | [React Resize Bounding](/packages/react/react-resize-bounding/README.md) | `npm i react-resize-bounding` | [stackblitz](https://stackblitz.com/edit/react-resize-bounding-example?file=src%2FApp.tsx), [github](https://github.com/yamogoo/resize-bounding/blob/v2.0.2/packages/react/playground/vite-app/src/components/InteractiveGrid.tsx) | ![Version](https://img.shields.io/badge/version-1.0.2-blue) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE) |
| ![image](/shared/images/vue-logo.svg) | [Vue3 Resize Bounding](/packages/vue/vue3-resize-bounding/README.md) | `npm i vue3-resize-bounding` | [stackblitz](https://stackblitz.com/edit/vue3-resize-bounding-example?file=src%2FApp.vue), [github](https://github.com/yamogoo/resize-bounding/blob/v2.0.3/packages/vue/playground/vite-app/src/components/InteractiveGrid.vue) | ![Version](https://img.shields.io/badge/version-2.0.3-green) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](./LICENSE) |
| ![image](/shared/images/react-logo.svg) | [React Resize Bounding](/packages/react/react-resize-bounding/README.md) | `npm i react-resize-bounding` | [stackblitz](https://stackblitz.com/edit/react-resize-bounding-example?file=src%2FApp.tsx), [github](https://github.com/yamogoo/resize-bounding/blob/v2.0.3/packages/react/playground/vite-app/src/components/InteractiveGrid.tsx) | ![Version](https://img.shields.io/badge/version-1.0.3-blue) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE) |
| ![image](/shared/images/figma-logo.svg) | UI Component for Figma | [link](https://www.figma.com/community/file/1392603830584852243) | | [![License: MIT](https://img.shields.io/badge/License-CCBY4.0-red.svg)](https://creativecommons.org/licenses/by/4.0/) |

[Demo](https://resize-bounding.netlify.app/)

![image](https://raw.githubusercontent.com/yamogoo/resize-bounding/v2.0.2/shared/images/resize-bounding.gif)
![image](https://raw.githubusercontent.com/yamogoo/resize-bounding/v2.0.3/shared/images/resize-bounding.gif)

---

Expand Down
3 changes: 1 addition & 2 deletions demo/components/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ interface CodeBlock {
const vue3: Array<CodeBlock> = [
{
lang: "html",
code: `<!-- @filename: MyComponent.vue -->
<script setup lang="ts">
code: `<script setup lang="ts">
import { ref } from "vue";
import ResizeBounding from "vue3-resize-bounding";
Expand Down
4 changes: 2 additions & 2 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "highly customizable component for resizing nested content",
"private": true,
"version": "1.0.1",
"productVueVersion": "2.0.2",
"productReactVersion": "1.0.2",
"productVueVersion": "2.0.3",
"productReactVersion": "1.0.3",
"type": "module",
"author": {
"name": "yamogoo",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"resize container",
"draggable container"
],
"vueVersion": "2.0.2",
"reactVersion": "1.0.2",
"vueVersion": "2.0.3",
"reactVersion": "1.0.3",
"private": false,
"author": {
"name": "yamogoo",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
$__border-color: gray;
$__background--primary: #e8ebec;

%container--normal {
background: $__background--primary;
}

.boundarize-app {
display: flex;
@include box(100%);
Expand All @@ -23,8 +16,6 @@ $__background--primary: #e8ebec;
display: flex;
flex-direction: column;
@include box(100%);
@extend %container--normal;
border: 1px solid $__border-color;
border-radius: 24px;
overflow: hidden;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import {
ActionTypes,
} from "./layout.store";

import { colors } from "@/components/colors";

const borderStyle = `1px solid ${colors.borderNormal}`;

const layoutReducer = (
state: typeof initState,
action: Actions,
Expand All @@ -41,15 +45,24 @@ const InteractiveGrid = () => {
const [layout, dispatch] = useReducer(layoutReducer, initState);

return (
<main className="boundarize-app">
<main
className="boundarize-app"
style={{ background: `${colors.backgroundApp}` }}
>
<div className="boundarize-app--container">
<div className="boundarize-app__layout">
<div
className="boundarize-app__layout"
style={{
background: `${colors.backgroundSecondary}`,
border: `1px solid ${colors.borderNormal}`,
}}
>
<ResizeBounding
height={layout.a.height}
minHeight={layout.a.minHeight}
maxHeight={layout.a.maxHeight}
directions="b"
style={{ borderBottom: "1px solid gray" }}
style={{ borderBottom: borderStyle }}
updateHeight={(height) => {
dispatch({ type: ActionTypes.SET_A_HEIGHT, payload: height });
}}
Expand All @@ -72,7 +85,7 @@ const InteractiveGrid = () => {
min-width={layout.b.minWidth}
max-width={layout.b.maxWidth}
directions="'r'"
style={{ display: "flex", borderRight: "1px solid gray" }}
style={{ display: "flex", borderRight: borderStyle }}
updateWidth={(width) => {
dispatch({ type: ActionTypes.SET_B_WIDTH, payload: width });
}}
Expand All @@ -94,7 +107,7 @@ const InteractiveGrid = () => {
min-width={layout.d.minWidth}
max-width={layout.d.maxWidth}
directions="'l'"
style={{ borderLeft: "1px solid gray" }}
style={{ borderLeft: borderStyle }}
updateWidth={(width) => {
dispatch({ type: ActionTypes.SET_D_WIDTH, payload: width });
}}
Expand All @@ -117,7 +130,7 @@ const InteractiveGrid = () => {
style={{
display: "flex",
width: "100%",
borderTop: "1px solid gray",
borderTop: borderStyle,
}}
updateHeight={(height) => {
dispatch({ type: ActionTypes.SET_E_HEIGHT, payload: height });
Expand All @@ -128,9 +141,7 @@ const InteractiveGrid = () => {
min-width={layout.e.minWidth}
max-width={layout.e.maxWidth}
directions="'r'"
style={{
borderRight: "1px solid gray",
}}
style={{ borderRight: borderStyle }}
updateWidth={(width) => {
dispatch({ type: ActionTypes.SET_E_WIDTH, payload: width });
}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,46 @@
import ResizeBoundingComponent, { type Props } from "react-resize-bounding";
import ResizeBoundingComponent, {
globalClassNames,
PREFIX,
type Props,
} from "react-resize-bounding";

import { colors } from "./colors";

const styles = {
splitter: [
globalClassNames(PREFIX).splitter,
{
[`.${globalClassNames(PREFIX).pane}.active &`]: {
background: `${colors.accent}`,
},
},
],
knob: [
globalClassNames(PREFIX).knob,
{
height: "10px",
borderRadius: "5px",
background: `${colors.resizerKnobNormal}`,
border: `2px solid ${colors.backgroundSecondary}`,
[`.${globalClassNames(PREFIX).pane}.active &`]: {
background: `${colors.accent}`,
},
},
],
};

const ResizeBounding = (props: Props) => {
return (
<ResizeBoundingComponent
{...props}
options={{
width: 6,
activeAreaWidth: 16,
knob: {
show: true,
},
}}
styles={styles}
>
{props.children}
</ResizeBoundingComponent>
Expand Down
10 changes: 10 additions & 0 deletions packages/react/playground/vite-app/src/components/colors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const colors = {
backgroundApp: "#171717",
backgroundPrimary: "#2B2B2B",
backgroundSecondary: "#171717",
foregroundPrimary: "#5a5a5a",
foregroundSecondary: "#C0C0C0",
borderNormal: "#313131",
accent: "#776AFF",
resizerKnobNormal: "#E1E1E1",
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
@include box(100%);
border-radius: 16px;
padding: 40px;
background-color: white;
}

&__control-panel {
Expand All @@ -21,8 +20,7 @@
}

h1 {
font-size: 44px;
font-weight: 600;
color: black;
font-size: 64px;
font-weight: 500;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { PropsWithChildren } from "react";

import { colors } from "@/components/colors";
import "./UIInnerBlock.scss";

interface Props extends PropsWithChildren {
Expand All @@ -8,7 +9,7 @@ interface Props extends PropsWithChildren {
imageDescription?: string;
}

const HInnerBlock = ({ title, imagePath }: Props) => {
const HInnerBlock = ({ children, title, imagePath }: Props) => {
return (
<div className={"ui-inner-block"}>
<div
Expand All @@ -17,12 +18,11 @@ const HInnerBlock = ({ title, imagePath }: Props) => {
backgroundImage: `url(${imagePath})`,
backgroundPosition: "center",
backgroundSize: "cover",
backgroundColor: colors.backgroundPrimary,
}}
>
<div className="ui-inner-block__control-panel">
<slot></slot>
</div>
<h1>{title}</h1>
<div className="ui-inner-block__control-panel">{children}</div>
<h1 style={{ color: colors.foregroundPrimary }}>{title}</h1>
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
$__background--primary: #e8ebec;

.ui {
&-size-field {
display: grid;
grid-template-columns: 1fr 1fr;
height: 36px;
background-color: $__background--primary;
border-radius: 24px;
color: black;

.ui-input {
&:not(:last-child) {
border-right: 1px solid rgba(0, 0, 0, 0.2);
border-right: 1px solid rgba(255, 255, 255, 0.2);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { PropsWithChildren } from "react";
import UIInput from "./UIInput";
import "./UISizeField.scss";

import { colors } from "@/components/colors";
interface Props extends PropsWithChildren {
width?: number;
height?: number;
Expand All @@ -13,7 +14,13 @@ interface Props extends PropsWithChildren {

const UISizeField = ({ width, height, updateWidth, updateHeight }: Props) => {
return (
<div className="ui-size-field">
<div
className="ui-size-field"
style={{
backgroundColor: colors.backgroundSecondary,
color: colors.foregroundSecondary,
}}
>
<UIInput
label={"W:"}
value={width}
Expand Down
8 changes: 4 additions & 4 deletions packages/react/react-resize-bounding/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
![image](https://raw.githubusercontent.com/yamogoo/resize-bounding/v2.0.2/shared/images/resize-bounding-w-descriptor.svg)
![Version](https://img.shields.io/badge/version-1.0.2-blue) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
![image](https://raw.githubusercontent.com/yamogoo/resize-bounding/v2.0.3/shared/images/resize-bounding-w-descriptor.svg)
![Version](https://img.shields.io/badge/version-1.0.3-blue) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)

**React Resize Bounding** is a simple, highly customizable React component that allows you to intuitively resize nested content using draggable border panels.

[Demo](https://resize-bounding.netlify.app/)

![image](https://raw.githubusercontent.com/yamogoo/resize-bounding/v2.0.2/shared/images/resize-bounding.gif)
![image](https://raw.githubusercontent.com/yamogoo/resize-bounding/v2.0.3/shared/images/resize-bounding.gif)

Interactive Grid (Example):

- [stackblitz](https://stackblitz.com/edit/react-resize-bounding-example?file=src%2FApp.tsx)
- [github](https://github.com/yamogoo/resize-bounding/blob/v2.0.2/packages/react/playground/vite-app/src/components/InteractiveGrid.tsx)
- [github](https://github.com/yamogoo/resize-bounding/blob/v2.0.3/packages/react/playground/vite-app/src/components/InteractiveGrid.tsx)

Installation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ const ResizeBoundingPane = ({

isResizing = true;
setIsPressed(true);

onSelected(isResizing);

const el = e.currentTarget as HTMLDivElement;
Expand All @@ -165,8 +164,6 @@ const ResizeBoundingPane = ({
isResizing = false;
setIsPressed(false);

updateCursor(isResizing);

const el = e.currentTarget as HTMLDivElement;
el.releasePointerCapture(e.pointerId);

Expand Down
5 changes: 4 additions & 1 deletion packages/react/react-resize-bounding/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-resize-bounding",
"description": "React highly customizable component for resizing nested content",
"version": "1.0.2",
"version": "1.0.3",
"license": "MIT",
"private": false,
"author": {
Expand Down Expand Up @@ -75,5 +75,8 @@
"vite": "^5.3.1",
"vite-plugin-dts": "^3.9.1",
"vitest": "^2.0.2"
},
"dependencies": {
"vue3-resize-bounding": "^2.0.2"
}
}
Loading

0 comments on commit 3046ae8

Please sign in to comment.