Skip to content

Commit

Permalink
add links support to stories (#334)
Browse files Browse the repository at this point in the history
* add links support to stories

* undo not needed changes
  • Loading branch information
Hadas Farhi authored Nov 16, 2021
1 parent 889b4a2 commit 77c8b8f
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 10 deletions.
6 changes: 4 additions & 2 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
UsageGuidelines,
RelatedComponents,
DocFooter,
MultipleStoryElementsWrapper
MultipleStoryElementsWrapper,
Link
} from "../src/storybook/components";

addParameters({
Expand All @@ -32,7 +33,8 @@ addParameters({
Tip,
ComponentRules,
UsageGuidelines,
RelatedComponents
RelatedComponents,
Link
}
},
viewMode: "docs",
Expand Down
2 changes: 1 addition & 1 deletion src/storybook/components/component-rule/component-rule.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const ComponentRule = ({ component, description, isRecommended }) => {

ComponentRule.propTypes = {
component: PropTypes.element,
description: PropTypes.string,
description: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
isRecommended: PropTypes.bool
};

Expand Down
4 changes: 2 additions & 2 deletions src/storybook/components/component-rules/component-rules.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ ComponentRules.propTypes = {
PropTypes.shape({
positive: PropTypes.shape({
component: PropTypes.element,
description: PropTypes.string
description: PropTypes.oneOfType([PropTypes.string, PropTypes.element])
}),
negative: PropTypes.shape({
component: PropTypes.element,
description: PropTypes.string
description: PropTypes.oneOfType([PropTypes.string, PropTypes.element])
})
})
)
Expand Down
4 changes: 3 additions & 1 deletion src/storybook/components/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { RelatedComponents } from "./related-components/related-components";
import { AnchorListItem } from "./anchor-list-item/anchor-list-item";
import { DocFooter } from "./doc-footer/doc-footer";
import { MultipleStoryElementsWrapper } from "./multiple-story-elements-wrapper/multiple-story-elements-wrapper";
import { Link } from "./link/link";

export {
SectionName,
Expand All @@ -19,5 +20,6 @@ export {
RelatedComponents,
AnchorListItem,
DocFooter,
MultipleStoryElementsWrapper
MultipleStoryElementsWrapper,
Link
};
36 changes: 36 additions & 0 deletions src/storybook/components/link/link.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import cx from "classnames";
import PropTypes from "prop-types";
import CoreLink from "../../../components/Link/Link";
import "./link.scss";
import { BEMClass } from "../../../helpers/bem-helper";

const BASE_CLASS = "monday-storybook-link";
const bemHelper = BEMClass(BASE_CLASS);

export const Link = ({ children, href, size }) => (
<CoreLink
text={children}
href={href}
componentClassName={cx(BASE_CLASS, {
[bemHelper({ state: "small" })]: size === Link.sizes.SMALL,
[bemHelper({ state: "medium" })]: size === Link.sizes.MEDIUM
})}
/>
);

Link.sizes = {
SMALL: "small",
MEDIUM: "medium"
};

Link.defaultProps = {
children: undefined,
href: undefined,
size: Link.sizes.SMALL
};

Link.propTypes = {
children: PropTypes.string,
href: PropTypes.string,
size: PropTypes.oneOf([Link.sizes.SMALL, Link.sizes.MEDIUM])
};
11 changes: 11 additions & 0 deletions src/storybook/components/link/link.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@import "../styles/typography.scss";

.monday-storybook-link {
display: inline-flex;
&--small {
@include paragraph-text-without-color;
}
&--medium {
@include content-text-without-color;
}
}
14 changes: 11 additions & 3 deletions src/storybook/components/styles/typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,23 @@ $text-line-height: 24px;
@include theme-prop(color, primary-text-color);
}

@mixin content-text {
@include basic-text;
@mixin content-text-without-color {
font-size: $text-font-size;
line-height: $text-line-height;
}

@mixin paragraph-text {
@mixin content-text {
@include content-text-without-color;
@include basic-text;
}

@mixin paragraph-text-without-color {
font-size: $small-text-font-size;
font-weight: 300;
line-height: $text-line-height;
}

@mixin paragraph-text {
@include basic-text;
@include paragraph-text-without-color;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const UsageGuidelines = ({ guidelines }) => {
};

UsageGuidelines.propTypes = {
guidelines: PropTypes.arrayOf(PropTypes.string)
guidelines: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.element]))
};

UsageGuidelines.defaultProps = {
Expand Down

0 comments on commit 77c8b8f

Please sign in to comment.