From 7a8b1c0c0684d9819a380c622215d84c68cd103c Mon Sep 17 00:00:00 2001 From: Florian Scholdei Date: Thu, 16 Apr 2020 12:34:28 +0200 Subject: [PATCH 1/4] Add iconStyle + onClick option and story shot for icon component --- CHANGELOG.md | 28 ++++++--- scm-ui/ui-components/src/Icon.stories.tsx | 62 +++++++++++++++++++ scm-ui/ui-components/src/Icon.tsx | 15 ++++- .../src/__snapshots__/storyshots.test.ts.snap | 40 ++++++++++++ 4 files changed, 132 insertions(+), 13 deletions(-) create mode 100644 scm-ui/ui-components/src/Icon.stories.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index 4209598c8d..3bdfe62c55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,20 +9,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Removed the `requires` attribute on the `@Extension` annotation and instead create a new `@Requires` annotation ([#1097](https://github.com/scm-manager/scm-manager/pull/1097)) -## 2.0.0-rc7 - 2020-04-09 +## [2.0.0-rc7] - 2020-04-09 ### Added - Fire various plugin events ([#1088](https://github.com/scm-manager/scm-manager/pull/1088)) -- Display version for plugins ([#1089](https://github.com/scm-manager/scm-manager/pull/1089) +- Display version for plugins ([#1089](https://github.com/scm-manager/scm-manager/pull/1089)) ### Changed -- Simplified collapse state management of the secondary navigation ([#1086](https://github.com/scm-manager/scm-manager/pull/1086) -- Ensure same monospace font-family throughout whole SCM-Manager ([#1091](https://github.com/scm-manager/scm-manager/pull/1091) +- Simplified collapse state management of the secondary navigation ([#1086](https://github.com/scm-manager/scm-manager/pull/1086)) +- Ensure same monospace font-family throughout whole SCM-Manager ([#1091](https://github.com/scm-manager/scm-manager/pull/1091)) ### Fixed - Authentication for write requests for repositories with anonymous read access ([#108](https://github.com/scm-manager/scm-manager/pull/1081)) - Submodules in git do no longer lead to a server error in the browser command ([#1093](https://github.com/scm-manager/scm-manager/pull/1093)) -## 2.0.0-rc6 - 2020-03-26 +## [2.0.0-rc6] - 2020-03-26 ### Added - Extension point to add links to the repository cards from plug ins ([#1041](https://github.com/scm-manager/scm-manager/pull/1041)) - Libc based restart strategy for posix operating systems ([#1079](https://github.com/scm-manager/scm-manager/pull/1079)) @@ -46,7 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Show specific notification for plugin actions on plugin administration ([#1057](https://github.com/scm-manager/scm-manager/pull/1057)) - Invalid markdown could make parts of the page inaccessible ([#1077](https://github.com/scm-manager/scm-manager/pull/1077)) -## 2.0.0-rc5 - 2020-03-12 +## [2.0.0-rc5] - 2020-03-12 ### Added - Added footer extension points for links and avatar - Create OpenAPI specification during build @@ -71,7 +71,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Enunciate rest documentation - Obsolete fields in data transfer objects -## 2.0.0-rc4 - 2020-02-14 +## [2.0.0-rc4] - 2020-02-14 ### Added - Support for Java versions > 8 - Simple ClassLoaderLifeCycle to fix integration tests on Java > 8 @@ -87,12 +87,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Committer of new Git commits set to "SCM-Manager " -## 2.0.0-rc3 - 2020-01-31 +## [2.0.0-rc3] - 2020-01-31 ### Fixed - Broken plugin order fixed - MarkdownViewer in code section renders markdown properly -## 2.0.0-rc2 - 2020-01-29 +## [2.0.0-rc2] - 2020-01-29 ### Added - Set individual page title - Copy on write @@ -115,7 +115,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Page title is now set correctly - Restart after migration -## 2.0.0-rc1 - 2019-12-02 +## [2.0.0-rc1] - 2019-12-02 ### Added - Namespace concept and endpoints - File history @@ -132,3 +132,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Anonymous access via git-clone and API access with anonymous user - Cache and x-requested-with header to bundle requests - remove public flag from repository and migrate permissions to anonymous user + +[2.0.0-rc1]: https://github.com/scm-manager/scm-manager/releases/tag/2.0.0-rc1 +[2.0.0-rc2]: https://github.com/scm-manager/scm-manager/releases/tag/2.0.0-rc2 +[2.0.0-rc3]: https://github.com/scm-manager/scm-manager/releases/tag/2.0.0-rc3 +[2.0.0-rc4]: https://github.com/scm-manager/scm-manager/releases/tag/2.0.0-rc4 +[2.0.0-rc5]: https://github.com/scm-manager/scm-manager/releases/tag/2.0.0-rc5 +[2.0.0-rc6]: https://github.com/scm-manager/scm-manager/releases/tag/2.0.0-rc6 +[2.0.0-rc7]: https://github.com/scm-manager/scm-manager/releases/tag/2.0.0-rc7 diff --git a/scm-ui/ui-components/src/Icon.stories.tsx b/scm-ui/ui-components/src/Icon.stories.tsx new file mode 100644 index 0000000000..8d4e2c2cd2 --- /dev/null +++ b/scm-ui/ui-components/src/Icon.stories.tsx @@ -0,0 +1,62 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * 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. + */ +import React, { FC } from "react"; +import { storiesOf } from "@storybook/react"; +import styled from "styled-components"; +import Icon from "./Icon"; + +const Wrapper = styled.div` + * { + margin: 0.5rem; + } +`; + +const Container: FC = ({ children }) => {children}; + +const helloWorld = () => { + alert("Hello world!"); +}; + +storiesOf("Icon", module) + .addDecorator(storyFn => {storyFn()}) + .add("default", () => ( + <> + + + + helloWorld()} + /> + + )) + .add("minimal", () => ( + <> + + + + + )); diff --git a/scm-ui/ui-components/src/Icon.tsx b/scm-ui/ui-components/src/Icon.tsx index e93979ed5d..4f44c661fe 100644 --- a/scm-ui/ui-components/src/Icon.tsx +++ b/scm-ui/ui-components/src/Icon.tsx @@ -26,21 +26,30 @@ import classNames from "classnames"; type Props = { title?: string; + iconStyle: string; name: string; color: string; className?: string; + onClick?: () => void; }; export default class Icon extends React.Component { static defaultProps = { + iconStyle: "fas", color: "grey-light" }; render() { - const { title, name, color, className } = this.props; + const { title, iconStyle, name, color, className, onClick } = this.props; if (title) { - return ; + return ( + + ); } - return ; + return ; } } diff --git a/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap b/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap index 26b6c0c320..05312337e3 100644 --- a/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap +++ b/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap @@ -32706,6 +32706,46 @@ exports[`Storyshots Forms|Textarea OnSubmit 1`] = ` `; +exports[`Storyshots Icon default 1`] = ` +
+ + + + +
+`; + +exports[`Storyshots Icon minimal 1`] = ` +
+ + + +
+`; + exports[`Storyshots Layout|Footer Default 1`] = `