@gitlab/ui 37.2.0 → 37.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -77,6 +77,7 @@ export const setupStorybookReadme = () =>
77
77
  'GlSorting',
78
78
  'GlSortingItem',
79
79
  'GlIcon',
80
+ 'GlSafeLinkDirective',
80
81
  'GlDashboardSkeleton',
81
82
  'GlToggle',
82
83
  'GlNavbar',
@@ -113,6 +114,7 @@ export const setupStorybookReadme = () =>
113
114
  'GlChartTooltip',
114
115
  'GlInputGroupText',
115
116
  'GlGaugeChart',
117
+ 'GlSafeHtmlDirective',
116
118
  'GlFormRadio',
117
119
  'GlModal',
118
120
  'GlKeysetPagination',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "37.2.0",
3
+ "version": "37.3.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -1,9 +1,5 @@
1
- # Safe Html
2
-
3
1
  A Vue Directive to sanitize HTML to avoid any XSS vulnerabilities.
4
2
 
5
- <!-- STORY -->
6
-
7
3
  ## Usage
8
4
 
9
5
  This directive can be used to sanitize HTML code which may contain user input, to prevent cross-site
@@ -1,50 +1,59 @@
1
- import { withKnobs, text } from '@storybook/addon-knobs';
2
1
  import { sanitize } from 'dompurify';
3
- import { escape } from 'lodash';
4
- import { documentedStoriesOf } from '../../../documentation/documented_stories';
5
- import { GlSafeHtmlDirective } from '../../index';
2
+ import { GlSafeHtmlDirective as GlSafeHtml } from '../../index';
6
3
  import readme from './safe_html.md';
7
4
 
8
- documentedStoriesOf('directives/safe-html-directive', readme)
9
- .addDecorator(withKnobs)
10
- .addParameters({ storyshots: false, knobs: { escapeHTML: false } })
11
- .add('default', () => ({
12
- directives: {
13
- 'gl-safe-html': GlSafeHtmlDirective,
14
- },
15
- props: {
16
- unsafeHTML: {
17
- type: String,
18
- default: text('Unsafe HTML', '<a href="javascript:alert(document.domain)">Click me</a>'),
19
- },
5
+ const generateProps = ({
6
+ unsafeHTML = '<a href="javascript:alert(document.domain)">Click me</a>',
7
+ } = {}) => ({
8
+ unsafeHTML,
9
+ });
10
+
11
+ export const Default = (_args, { argTypes }) => ({
12
+ directives: {
13
+ GlSafeHtml,
14
+ },
15
+ props: Object.keys(argTypes),
16
+ computed: {
17
+ sanitizedHtml() {
18
+ return sanitize(this.unsafeHTML);
20
19
  },
21
- computed: {
22
- sanitizedHtml() {
23
- return sanitize(this.unsafeHTML);
20
+ },
21
+ template: `
22
+ <table class="gl-table">
23
+ <thead>
24
+ <tr>
25
+ <th>Directive</th>
26
+ <th>Output</th>
27
+ <th>Rendered</th>
28
+ </tr>
29
+ </thead>
30
+ <tbody>
31
+ <tr>
32
+ <td><strong>v-html</strong></td>
33
+ <td><code>{{ unsafeHTML }}</code></td>
34
+ <td>N/A for security reasons</td>
35
+ </tr>
36
+ <tr>
37
+ <td><strong>v-safe-html</strong></td>
38
+ <td><code>{{ sanitizedHtml }}</code></td>
39
+ <td v-gl-safe-html="unsafeHTML"></td>
40
+ </tr>
41
+ </tbody>
42
+ </table>
43
+ `,
44
+ });
45
+ Default.args = generateProps();
46
+
47
+ export default {
48
+ title: 'directives/safe-html-directive',
49
+ component: GlSafeHtml,
50
+ parameters: {
51
+ storyshots: { disable: true },
52
+ knobs: { disable: true },
53
+ docs: {
54
+ description: {
55
+ component: readme,
24
56
  },
25
57
  },
26
- escape,
27
- template: `
28
- <table class="gl-table">
29
- <thead>
30
- <tr>
31
- <th>Directive</th>
32
- <th>Output</th>
33
- <th>Rendered</th>
34
- </tr>
35
- </thead>
36
- <tbody>
37
- <tr>
38
- <td><strong>v-html</strong></td>
39
- <td><code v-html="$options.escape(unsafeHTML)"></code></td>
40
- <td>N/A for security reasons</td>
41
- </tr>
42
- <tr>
43
- <td><strong>v-safe-html</strong></td>
44
- <td><code v-html="$options.escape(sanitizedHtml)"></code></td>
45
- <td v-gl-safe-html="unsafeHTML"></td>
46
- </tr>
47
- </tbody>
48
- </table>
49
- `,
50
- }));
58
+ },
59
+ };
@@ -3,5 +3,4 @@ import description from './safe_link.md';
3
3
  export default {
4
4
  followsDesignSystem: false,
5
5
  description,
6
- examples: false,
7
6
  };
@@ -1,9 +1,5 @@
1
- # Safe Link Directive
2
-
3
1
  A Vue directive to make the hyperlinks secure by default.
4
2
 
5
- <!-- STORY -->
6
-
7
3
  ## Security measures
8
4
 
9
5
  ### rel
@@ -1,6 +1,3 @@
1
- import { withKnobs, text, select } from '@storybook/addon-knobs';
2
- import { documentedStoriesOf } from '../../../documentation/documented_stories';
3
- import { targetOptions } from '../../utils/constants';
4
1
  import { SafeLinkDirective as SafeLink } from './safe_link';
5
2
  import readme from './safe_link.md';
6
3
 
@@ -9,31 +6,35 @@ const directives = {
9
6
  };
10
7
 
11
8
  // eslint-disable-next-line no-script-url
12
- function generateProps({ href = 'javascript:alert(1)', target = '_blank' } = {}) {
13
- return {
14
- href: {
15
- type: String,
16
- default: text('href', href),
17
- },
18
- target: {
19
- type: String,
20
- default: select('target', targetOptions, target),
21
- },
22
- };
23
- }
9
+ const generateProps = ({ href = 'javascript:alert(1)', target = '_blank' } = {}) => ({
10
+ href,
11
+ target,
12
+ });
13
+
14
+ export const Default = (_args, { argTypes }) => ({
15
+ props: Object.keys(argTypes),
16
+ directives,
17
+ template: `
18
+ <a
19
+ :href="href"
20
+ :target="target"
21
+ v-safe-link
22
+ >
23
+ This is a secure link
24
+ </a>`,
25
+ });
26
+ Default.args = generateProps();
24
27
 
25
- documentedStoriesOf('directives/safe-link-directive', readme)
26
- .addParameters({ storyshots: false })
27
- .addDecorator(withKnobs)
28
- .add('default', () => ({
29
- props: generateProps(),
30
- directives,
31
- template: `
32
- <a
33
- :href="href"
34
- :target="target"
35
- v-safe-link
36
- >
37
- This is a secure link
38
- </a>`,
39
- }));
28
+ export default {
29
+ title: 'directives/safe-link-directive',
30
+ component: SafeLink,
31
+ parameters: {
32
+ knobs: { disable: true },
33
+ storyshots: { disable: true },
34
+ docs: {
35
+ description: {
36
+ component: readme,
37
+ },
38
+ },
39
+ },
40
+ };
@@ -410,6 +410,14 @@
410
410
  background-color: $orange-700 !important
411
411
  }
412
412
 
413
+ .gl-bg-purple-50 {
414
+ background-color: $purple-50
415
+ }
416
+
417
+ .gl-bg-purple-50\! {
418
+ background-color: $purple-50 !important
419
+ }
420
+
413
421
  .gl-bg-red-50 {
414
422
  background-color: $red-50
415
423
  }
@@ -142,6 +142,10 @@
142
142
  background-color: $orange-700;
143
143
  }
144
144
 
145
+ @mixin gl-bg-purple-50 {
146
+ background-color: $purple-50;
147
+ }
148
+
145
149
  @mixin gl-bg-red-50 {
146
150
  background-color: $red-50;
147
151
  }