From 1135e7c5485dbac41ddd1d442d36b289d7348fbc Mon Sep 17 00:00:00 2001 From: Tara O'Kelly Date: Thu, 6 Jun 2019 08:40:33 +0100 Subject: [PATCH] Swagger ui redesign/custom dropdown (via #5381) * improvement: OAS3 $ref friendly-name regex in model.jsx (via #5334) * improvement: relax schema description styling so Markdown can be effective (via #5340) * improvement: add `isShown` check to 's prop `expanded` logic (via #5331) * Add and apply default button classes, styling * Update buttons to use custom component * Fix breaking unit tests * Replace button transition, replace EOF new-line * Apply custom sui-btn-wrapper class * Add span wrapper for button-text (allows us to apply em padding / margins on button element) * security: CVE-2018-20834 (via #5368) * bump minimum `bundlesize` version * bump `node-sass` * bump webpack + webpack-dev-server; update lockfile * release: v3.22.2 * Abstract default classnames to Button component * Use classnames lib where applicable * Fix unit tests * Tidy up, remove unused classnames * eliminate `auth` class * eliminate `authorize` class * move `.sui-btn--authorize` to buttons stylesheet * Remove duplicate import after merge * Dropdown component set up * Dropdown id & custom class props * Dropdown disabled prop * Basic DropDownItem, Updated Dropdown child classnames to not inherit modifer * Layout-utils restucture * Dropdown Basic controls * Dropdown Labels * Moved Dropdown to LayoutUtils * Dropdowm relocation cleanup * Dropdowm relocation cleanup P2 * Dropdown refs rough draft * Dropdown movement controls * Dropdown select option functionality * Dropdown default selected value and default placeholder * Add temporary dropdown icon - to be replaced by fontawesome * Move clickhandler to li element * Wrap dropdown text in span * Update alter-hue mixin to accept custom degree * Update dropdown styling * Apply custom Dropdown to "schemes" * Dropdown onChange * Removed Dropdown labels * Dropdown classname improvements * IE/Edge specific keyboard event keys * Removed onKeyPress * Dropdown classname improvements * Dropdown move item focus function * Dropdown move item focus function update * Replaced xclass with classnames * Dropdown styling * Dropdown seperate children function * Dropdown icon * Dropdown error handling - no children * Dropdown no options available msg --- src/core/components/layout-utils.jsx | 272 --------------- src/core/components/layout-utils/button.jsx | 31 ++ src/core/components/layout-utils/col.jsx | 69 ++++ src/core/components/layout-utils/collapse.jsx | 43 +++ .../components/layout-utils/container.jsx | 24 ++ .../components/layout-utils/drop-down.jsx | 316 ++++++++++++++++++ src/core/components/layout-utils/icon.jsx | 13 + src/core/components/layout-utils/index.js | 12 + src/core/components/layout-utils/input.jsx | 5 + src/core/components/layout-utils/link.jsx | 15 + .../components/layout-utils/no-margin.jsx | 10 + src/core/components/layout-utils/row.jsx | 15 + src/core/components/layout-utils/select.jsx | 70 ++++ src/core/components/layout-utils/textarea.jsx | 5 + src/core/components/schemes.jsx | 16 +- src/style/_dropdown.scss | 89 +++++ src/style/_mixins.scss | 6 +- src/style/main.scss | 1 + 18 files changed, 730 insertions(+), 282 deletions(-) delete mode 100644 src/core/components/layout-utils.jsx create mode 100644 src/core/components/layout-utils/button.jsx create mode 100644 src/core/components/layout-utils/col.jsx create mode 100644 src/core/components/layout-utils/collapse.jsx create mode 100644 src/core/components/layout-utils/container.jsx create mode 100644 src/core/components/layout-utils/drop-down.jsx create mode 100644 src/core/components/layout-utils/icon.jsx create mode 100644 src/core/components/layout-utils/index.js create mode 100644 src/core/components/layout-utils/input.jsx create mode 100644 src/core/components/layout-utils/link.jsx create mode 100644 src/core/components/layout-utils/no-margin.jsx create mode 100644 src/core/components/layout-utils/row.jsx create mode 100644 src/core/components/layout-utils/select.jsx create mode 100644 src/core/components/layout-utils/textarea.jsx create mode 100644 src/style/_dropdown.scss diff --git a/src/core/components/layout-utils.jsx b/src/core/components/layout-utils.jsx deleted file mode 100644 index 6879d83ed25..00000000000 --- a/src/core/components/layout-utils.jsx +++ /dev/null @@ -1,272 +0,0 @@ -import React from "react" -import PropTypes from "prop-types" - -function xclass(...args) { - return args.filter(a => !!a).join(" ").trim() -} - -export class Container extends React.Component { - render() { - let { fullscreen, full, ...rest } = this.props - // Normal element - - if(fullscreen) - return
- - let containerClass = "swagger-container" + (full ? "-full" : "") - return ( -
- ) - } -} - -Container.propTypes = { - fullscreen: PropTypes.bool, - full: PropTypes.bool, - className: PropTypes.string -} - -const DEVICES = { - "mobile": "", - "tablet": "-tablet", - "desktop": "-desktop", - "large": "-hd" -} - -export class Col extends React.Component { - - render() { - const { - hide, - keepContents, - /* we don't want these in the `rest` object that passes to the final component, - since React now complains. So we extract them */ - /* eslint-disable no-unused-vars */ - mobile, - tablet, - desktop, - large, - /* eslint-enable no-unused-vars */ - ...rest - } = this.props - - if(hide && !keepContents) - return - - let classesAr = [] - - for (let device in DEVICES) { - if (!DEVICES.hasOwnProperty(device)) { - continue - } - let deviceClass = DEVICES[device] - if(device in this.props) { - let val = this.props[device] - - if(val < 1) { - classesAr.push("none" + deviceClass) - continue - } - - classesAr.push("block" + deviceClass) - classesAr.push("col-" + val + deviceClass) - } - } - - let classes = xclass(rest.className, ...classesAr) - - return ( -
- ) - } - -} - -Col.propTypes = { - hide: PropTypes.bool, - keepContents: PropTypes.bool, - mobile: PropTypes.number, - tablet: PropTypes.number, - desktop: PropTypes.number, - large: PropTypes.number, - className: PropTypes.string -} - -export class Row extends React.Component { - - render() { - return
- } - -} - -Row.propTypes = { - className: PropTypes.string -} - -export class Button extends React.Component { - - static propTypes = { - className: PropTypes.string, - unstyled: PropTypes.bool, - mod: PropTypes.string - } - - static defaultProps = { - className: "", - unstyled: false, - mod: "primary" - } - - defaultClasses = ({ unstyled, mod }) => !unstyled ? `sui-btn sui-btn--${mod}` : "" - - render() { - const { unstyled, mod, className, ...props } = this.props - - return ( -