Skip to content

Commit

Permalink
Fix floater behaviour (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
rogaldh authored Mar 23, 2021
1 parent 6050185 commit 32edee5
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/drawing-toolbar/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/drawing-toolbar/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ulms/ui-drawing-toolbar",
"version": "1.0.2",
"version": "1.0.3",
"description": "",
"keywords": [
"lerna"
Expand Down
6 changes: 3 additions & 3 deletions packages/drawing-toolbar/src/drawing-toolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export class DrawingToolbar extends React.Component {

if (opened === null) return

// TODO: remove implicit functional based on classnames
const closestToolbarElement = event.target.closest(`.${css.root}`)
const closestFloaterElement = event.target.closest(`.${css.floater}`)

Expand Down Expand Up @@ -250,7 +251,7 @@ export class DrawingToolbar extends React.Component {

{ isColorEnabled && (
<div
className={cn(css.button, 'group-color', { [css.active]: opened === 'group-color' })}
className={cn(css.button, css.group, 'group-color', { [css.active]: opened === 'group-color' })}
onClick={this.handleColorClick}
onKeyDown={this.handleColorClick}
role='button'
Expand Down Expand Up @@ -406,8 +407,8 @@ export class DrawingToolbar extends React.Component {

{ isEraserEnabled && (
<GroupEraser
eraserWidth={eraserWidth}
css={css}
eraserWidth={eraserWidth}
handleChange={handleChange}
opened={opened}
/>
Expand All @@ -419,7 +420,6 @@ export class DrawingToolbar extends React.Component {
css={css}
handleChange={handleChange}
opened={opened}
tool={tool}
/>
)}

Expand Down
18 changes: 10 additions & 8 deletions packages/drawing-toolbar/src/drawing-toolbar.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@
pointer-events: none;
}

.button.group::after {
.group {
display: flex;
align-items: center;
justify-content: center;
}
.group::after {
width: 0;
height: 0;
position: absolute;
Expand All @@ -63,12 +68,7 @@
right: 3px;
}

.button.group {
display: flex;
align-items: center;
justify-content: center;
}

/* TODO: get rid of duplicated popover and floater styles */
.popover {
padding: 12px;
position: relative;
Expand All @@ -79,7 +79,9 @@
border-radius: 5px;
user-select: none;
}
.floater {}
.floater {
user-select: none;
}

.row {
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion packages/drawing-toolbar/src/group-eraser.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import Floater from 'react-floater'
import Slider from 'rc-slider/lib/Slider'

export const GroupEraser = ({
eraserWidth,
css,
eraserWidth,
handleChange,
opened,
}) => (
Expand Down
6 changes: 3 additions & 3 deletions packages/drawing-toolbar/src/group-shape.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ export const GroupShape = ({
<Floater
component={() => (
<div
className={css.popover}
className={cn(css.popover, css.floater)}
style={{ color: toCSSColor(brushColor) }}
>
<div className={css.row}>
{
shapeToolModeList.map(({
icon, mode, solid,
}, index) => (
}) => (
<div
className={cn(css.button, {
[css.active]: shapeMode === mode && tool === toolEnum.SHAPE,
})}
key={index}
key={`${mode}-${solid}`}
onClick={() => handleChange({ shapeMode: mode, tool: toolEnum.SHAPE })}
role='button'
tabIndex='0'
Expand Down

0 comments on commit 32edee5

Please sign in to comment.