@bbl-digital/snorre 4.0.13 → 4.0.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,22 +1,23 @@
1
1
  import Html from '.';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { jsxs as _jsxs } from "react/jsx-runtime";
4
- export default {
4
+ const meta = {
5
5
  title: 'Core/Html',
6
6
  component: Html
7
7
  };
8
+ export default meta;
8
9
  export const HtmlDefault = {
9
- render: () => /*#__PURE__*/_jsx(Html, {
10
- text: "<h3>Html text</h3><p><i>Displays text as html</i></p>"
11
- }),
12
- name: 'Html'
10
+ name: 'Html',
11
+ args: {
12
+ text: '<h3>Html text</h3><p><i>Displays text as html</i></p>'
13
+ }
13
14
  };
14
15
  export const ExternalLinks = {
15
- render: () => /*#__PURE__*/_jsx(Html, {
16
+ name: 'External links',
17
+ args: {
16
18
  externalLinks: true,
17
- text: "<h3>Html text</h3><p><i>Displays text as html</i><a href='vg.no'>vg.no</a></p>"
18
- }),
19
- name: 'External links'
19
+ text: '<h3>Html text</h3><p><i>Displays text as html</i><a href="vg.no">vg.no</a></p>'
20
+ }
20
21
  };
21
22
  export const Whitespace = {
22
23
  render: () => /*#__PURE__*/_jsxs("div", {
@@ -35,9 +36,9 @@ export const Whitespace = {
35
36
  name: 'Whitespace'
36
37
  };
37
38
  export const RemoveMargins = {
38
- render: () => /*#__PURE__*/_jsx(Html, {
39
+ name: 'Remove margins',
40
+ args: {
39
41
  removeMargins: true,
40
42
  text: '<h1>Header</h1><p>Hello</p><p>New line</p>'
41
- }),
42
- name: 'Remove margins'
43
+ }
43
44
  };
@@ -1,13 +1,20 @@
1
1
  /** @jsxImportSource @emotion/react */
2
- import React from 'react';
3
2
  import { styles } from './styles';
4
3
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
5
- const Html = props => {
6
- return _jsx("div", {
7
- css: theme => [styles.default(theme), props.secondary && styles.secondary(theme), props.dark && styles.dark(theme), props.size && styles.size(props.size), styles.whiteSpace(props.whiteSpace ? props.whiteSpace : 'pre-wrap'), props.removeMargins && styles.removeMargins],
8
- dangerouslySetInnerHTML: {
9
- __html: props.externalLinks ? props.text.replace(/href/g, "target='_blank' href") : props.text
10
- }
11
- });
12
- };
4
+ const Html = ({
5
+ className,
6
+ dark,
7
+ externalLinks,
8
+ removeMargins,
9
+ secondary,
10
+ size,
11
+ text,
12
+ whiteSpace
13
+ }) => _jsx("div", {
14
+ css: theme => [styles.default(theme), secondary && styles.secondary(theme), dark && styles.dark(theme), size && styles.size(size), styles.whiteSpace(whiteSpace ? whiteSpace : 'pre-wrap'), removeMargins && styles.removeMargins],
15
+ className: className,
16
+ dangerouslySetInnerHTML: {
17
+ __html: externalLinks ? text.replace(/href/g, "target='_blank' href") : text
18
+ }
19
+ });
13
20
  export default Html;
@@ -128,6 +128,21 @@ export const CardInput = {
128
128
  },
129
129
  name: 'CardInput'
130
130
  };
131
+ export const Invalid = {
132
+ args: {
133
+ label: 'Invalid',
134
+ invalid: true,
135
+ invalidMessage: 'error'
136
+ },
137
+ name: 'Invalid'
138
+ };
139
+ export const InvalidNoLabel = {
140
+ args: {
141
+ invalid: true,
142
+ invalidMessage: 'error'
143
+ },
144
+ name: 'Invalid no label'
145
+ };
131
146
  export const Controls = {
132
147
  args: {
133
148
  label: 'With info',
@@ -91,7 +91,7 @@ const Input = /*#__PURE__*/React.forwardRef(({
91
91
  }), type === 'search' && _jsx(IconSearch, {}), props.invalidMessage && _jsx(IconErrorOutline, {
92
92
  size: "16px"
93
93
  }), props.invalidMessage && _jsx("span", {
94
- css: styles.errorMessage,
94
+ css: (styles.errorMessage, !props?.label && styles.errorMessageNoLabel),
95
95
  children: props.invalidMessage
96
96
  })]
97
97
  }), info && _jsx("span", {