From 41722923d5f88202a9876966ae57cca0a8a4ea61 Mon Sep 17 00:00:00 2001 From: aluc Date: Mon, 15 Jun 2020 06:22:08 +0900 Subject: [PATCH] add 'width' option for Carbon container (#949) * feat: add 'width' option for Carbon container * feat: draggable width adjustment * chore: auto disable widthAdjustment when edge starts dragging * remove label width default; tweak settings style * use only right width handler * use react effects, add a11y role and props * clean up code * use clamp fn * move max and min widths out of state * give WidthHandler a display name * tweak variable names Co-authored-by: Mike Fix Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com> --- components/Carbon.js | 31 +++++++++++----- components/Editor.js | 2 ++ components/Settings.js | 22 +++++++++++- components/WidthHandler.js | 73 ++++++++++++++++++++++++++++++++++++++ lib/constants.js | 6 ++++ 5 files changed, 124 insertions(+), 10 deletions(-) create mode 100644 components/WidthHandler.js diff --git a/components/Carbon.js b/components/Carbon.js index df82221..291c256 100644 --- a/components/Carbon.js +++ b/components/Carbon.js @@ -11,6 +11,7 @@ hljs.registerLanguage('javascript', javascript) import SpinnerWrapper from './SpinnerWrapper' import WindowControls from './WindowControls' +import WidthHandler from './WidthHandler' import { COLORS, @@ -201,12 +202,19 @@ class Carbon extends React.PureComponent {
+ + +
+ ) +} diff --git a/lib/constants.js b/lib/constants.js index f6b1863..ee85b8c 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -1092,6 +1092,12 @@ export const DEFAULT_SETTINGS = { squaredImage: false, hiddenCharacters: false, name: '', + width: 680, +} + +export const DEFAULT_WIDTHS = { + minWidth: 320, + maxWidth: 1280, } export const DEFAULT_PRESETS = [