index
int64
0
0
repo_id
stringlengths
16
181
file_path
stringlengths
28
270
content
stringlengths
1
11.6M
__index_level_0__
int64
0
10k
0
petrpan-code/ProtonMail/WebClients/applications/storybook
petrpan-code/ProtonMail/WebClients/applications/storybook/.storybook/manager-head.html
<style> #storybook-explorer-tree .sidebar-item svg { color: #6d4aff; } #storybook-explorer-tree .sidebar-item[data-selected='true'] svg { color: #fff; } .sidebar-header div:first-of-type a { color: #6d4aff; } #storybook-explorer-menu .sidebar-item { margin: 0 3px; border-radius: 3px; max-width: calc(100% - 6px); } #storybook-explorer-menu .sidebar-item:hover:not([data-selected='true']), #storybook-explorer-menu .sidebar-item:focus:not([data-selected='true']) { background-color: #f0edff; } </style>
4,500
0
petrpan-code/ProtonMail/WebClients/applications/storybook
petrpan-code/ProtonMail/WebClients/applications/storybook/.storybook/manager.js
import { addons } from '@storybook/addons'; import { themes } from '@storybook/theming'; import theme from './theme'; addons.setConfig({ theme: theme, showToolbar: true, });
4,501
0
petrpan-code/ProtonMail/WebClients/applications/storybook
petrpan-code/ProtonMail/WebClients/applications/storybook/.storybook/preview-head.html
<script src="prismjs.js"></script> <link rel="shortcut icon" href="/favicon.ico" /> <link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16" /> <link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32" />
4,502
0
petrpan-code/ProtonMail/WebClients/applications/storybook
petrpan-code/ProtonMail/WebClients/applications/storybook/.storybook/preview.js
import { BrowserRouter as Router } from 'react-router-dom'; import { CacheProvider, Icons, ModalsChildren, ModalsProvider, NotificationsChildren, NotificationsProvider, ThemeProvider, } from '@proton/components'; import ApiProvider from '@proton/components/containers/api/ApiProvider'; import ConfigProvider from '@proton/components/containers/config/Provider'; import createCache from '@proton/shared/lib/helpers/cache'; import { PROTON_DEFAULT_THEME, PROTON_THEMES_MAP, getThemes } from '@proton/shared/lib/themes/themes'; import * as config from '../src/app/config'; import './prismjs.js'; import storybookTheme from './theme'; import '../src/app/index.scss'; const cacheRef = createCache(); const tempConfig = { ...config, APP_NAME: 'proton-mail', }; const colorSchemes = ['default', 'ui-alias', 'ui-note', 'ui-password', 'ui-login']; const themes = getThemes(true); export const globalTypes = { theme: { name: 'Theme', description: 'Proton theme, globally applied to stories', defaultValue: PROTON_THEMES_MAP[PROTON_DEFAULT_THEME].label, toolbar: { icon: 'paintbrush', items: themes.map(({ label }) => label), showName: true, title: 'Theme', dynamicTitle: true, }, }, scheme: { name: 'Color Scheme', description: 'Pass specific color schemes', defaultValue: 'default', toolbar: { icon: 'paintbrush', items: colorSchemes.map((label) => label), showName: true, title: 'Scheme', dynamicTitle: true, }, }, }; export const decorators = [ (Story, context) => { const { theme: themeGlobal } = context.globals; const identifier = themes.find((theme) => theme.label === themeGlobal)?.identifier; const initialTheme = identifier || PROTON_DEFAULT_THEME; return ( <Router> <ConfigProvider config={tempConfig}> <ThemeProvider initial={initialTheme}> <Icons /> <NotificationsProvider> <ModalsProvider> <ApiProvider config={tempConfig}> <NotificationsChildren /> <ModalsChildren /> <CacheProvider cache={cacheRef}> <Story /> </CacheProvider> </ApiProvider> </ModalsProvider> </NotificationsProvider> </ThemeProvider> </ConfigProvider> </Router> ); }, (Story, context) => { return ( <div className={context.globals.scheme}> <Story /> </div> ); }, ]; const order = [ 'introduction-', 'changelog-', 'core-concepts-', '-theming-explanations-', '-theming-usage-', '-theming-taxonomy-', 'components-', 'css-utilities-', ]; export const parameters = { viewMode: 'docs', actions: { argTypesRegex: '^on[A-Z].*' }, controls: { expanded: true }, docs: { theme: storybookTheme }, previewTabs: { canvas: { hidden: true }, }, options: { storySort: (a, b) => { const aName = a[0]; const bName = b[0]; if (order.some((name) => aName.includes(name) || bName.includes(name))) { const aIdx = order.findIndex((i) => aName.indexOf(i) > -1); const bIdx = order.findIndex((i) => bName.indexOf(i) > -1); return aIdx - bIdx; } return a[1].kind === b[1].kind ? 0 : a[1].id.localeCompare(b[1].id, undefined, { numeric: true }); }, }, };
4,503
0
petrpan-code/ProtonMail/WebClients/applications/storybook
petrpan-code/ProtonMail/WebClients/applications/storybook/.storybook/prismjs.css
/* prism */ /** * prism.js default theme for JavaScript, CSS and HTML * Based on dabblet (http://dabblet.com) * @author Lea Verou */ code { display: inline-block !important; font-size: 1.1em !important; padding: 0.25em !important; border-radius: 5px !important; background: #f6f7fa !important !important; line-height: 1 !important; } code[class*='language-'], pre[class*='language-'] { width: 100% !important; color: black !important; text-shadow: 0 1px white !important; font-family: Consolas, Monaco, monospace !important; text-align: left !important; /*white-space: pre !important;*/ word-spacing: normal !important; font-size: 1.6rem !important; -moz-tab-size: 4 !important; -o-tab-size: 4 !important; tab-size: 4 !important; -webkit-hyphens: none !important; -moz-hyphens: none !important; -ms-hyphens: none !important; hyphens: none !important; border-radius: 5px !important; } [dir='rtl'] code[class*='language-'], [dir='rtl'] pre[class*='language-'] { text-align: right !important; } [dir='ltr'] code[class*='language-'], [dir='ltr'] pre[class*='language-'] { text-align: left !important; } /* Code blocks */ pre[class*='language-'] { padding: 1em !important; margin: 0.5em 0 !important; overflow: auto !important; } pre[class*='language-'].m-0 { margin: 0 !important; } :not(pre) > code[class*='language-'], pre[class*='language-'] { background: #f6f7fa !important; } /* Inline code */ :not(pre) > code[class*='language-'] { padding: 0.1em !important; border-radius: 0.3em !important; font-size: 0.8em !important; } .token.comment, .token.prolog, .token.doctype, .token.cdata { color: #344559 !important; } .token.punctuation { color: #4a4646 !important !important; } .namespace { opacity: 0.7 !important; } .token.property, .token.tag, .token.boolean, .token.number, .token.function, .token.class-name, .token.constant { color: #905 !important; } .token.selector, .token.attr-name, .token.string { color: #085300 !important; } .token.operator, .token.entity, .token.url, .language-css .token.string, .style .token.string { color: #803c24 !important !important; background: rgba(255, 255, 255, 0.5) !important; } .token.atrule, .token.attr-value, .token.keyword { color: #0227a9 !important; } .token.regex, .token.important { color: #e90 !important; } .token.important { font-weight: bold !important; } .token.entity { cursor: help !important; } @media (prefers-color-scheme: dark) { code { background: #262a33 !important; } code[class*='language-'], pre[class*='language-'] { color: #ccc !important; background: none !important; font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace !important; text-shadow: none !important; font-size: 1.4rem !important; text-align: left !important; white-space: pre !important; word-spacing: normal !important; word-break: normal !important; word-wrap: normal !important; line-height: 1.5 !important; -moz-tab-size: 4 !important; -o-tab-size: 4 !important; tab-size: 4 !important; -webkit-hyphens: none !important; -moz-hyphens: none !important; -ms-hyphens: none !important; hyphens: none !important; } /* Code blocks */ pre[class*='language-'] { padding: 1em !important; margin: 0.5em 0 !important; overflow: auto !important; } :not(pre) > code[class*='language-'], pre[class*='language-'] { background: #2d2d2d !important; } /* Inline code */ :not(pre) > code[class*='language-'] { padding: 0.1em !important; border-radius: 0.3em !important; white-space: normal !important; } .token.comment, .token.block-comment, .token.prolog, .token.doctype, .token.cdata { color: #999 !important; } .token.punctuation { color: #ccc !important; } .token.tag, .token.attr-name, .token.namespace, .token.deleted { color: #e2777a !important; } .token.function-name { color: #6196cc !important; } .token.boolean, .token.number, .token.function { color: #f08d49 !important; } .token.property, .token.class-name, .token.constant, .token.symbol { color: #f8c555 !important; } .token.selector, .token.important, .token.atrule, .token.keyword, .token.builtin { color: #cc99cd !important; } .token.string, .token.char, .token.attr-value, .token.regex, .token.variable { color: #7ec699 !important; } .token.operator, .token.entity, .token.url { color: #67cdcc !important; } .token.important, .token.bold { font-weight: bold !important; } .token.italic { font-style: italic !important; } .token.entity { cursor: help !important; } .token.inserted { color: green !important; } }
4,504
0
petrpan-code/ProtonMail/WebClients/applications/storybook
petrpan-code/ProtonMail/WebClients/applications/storybook/.storybook/prismjs.js
/* PrismJS 1.15.0 https://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript&plugins=keep-markup */ var _self = 'undefined' != typeof window ? window : 'undefined' != typeof WorkerGlobalScope && self instanceof WorkerGlobalScope ? self : {}, Prism = (function () { var e = /\blang(?:uage)?-([\w-]+)\b/i, t = 0, n = (_self.Prism = { manual: _self.Prism && _self.Prism.manual, disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler, util: { encode: function (e) { return e instanceof a ? new a(e.type, n.util.encode(e.content), e.alias) : 'Array' === n.util.type(e) ? e.map(n.util.encode) : e .replace(/&/g, '&amp;') .replace(/</g, '&lt;') .replace(/\u00a0/g, ' '); }, type: function (e) { return Object.prototype.toString.call(e).slice(8, -1); }, objId: function (e) { return e.__id || Object.defineProperty(e, '__id', { value: ++t }), e.__id; }, clone: function (e, t) { var a = n.util.type(e); switch (((t = t || {}), a)) { case 'Object': if (t[n.util.objId(e)]) return t[n.util.objId(e)]; var r = {}; t[n.util.objId(e)] = r; for (var l in e) e.hasOwnProperty(l) && (r[l] = n.util.clone(e[l], t)); return r; case 'Array': if (t[n.util.objId(e)]) return t[n.util.objId(e)]; var r = []; return ( (t[n.util.objId(e)] = r), e.forEach(function (e, a) { r[a] = n.util.clone(e, t); }), r ); } return e; }, }, languages: { extend: function (e, t) { var a = n.util.clone(n.languages[e]); for (var r in t) a[r] = t[r]; return a; }, insertBefore: function (e, t, a, r) { r = r || n.languages; var l = r[e], i = {}; for (var o in l) if (l.hasOwnProperty(o)) { if (o == t) for (var s in a) a.hasOwnProperty(s) && (i[s] = a[s]); a.hasOwnProperty(o) || (i[o] = l[o]); } var u = r[e]; return ( (r[e] = i), n.languages.DFS(n.languages, function (t, n) { n === u && t != e && (this[t] = i); }), i ); }, DFS: function (e, t, a, r) { r = r || {}; for (var l in e) e.hasOwnProperty(l) && (t.call(e, l, e[l], a || l), 'Object' !== n.util.type(e[l]) || r[n.util.objId(e[l])] ? 'Array' !== n.util.type(e[l]) || r[n.util.objId(e[l])] || ((r[n.util.objId(e[l])] = !0), n.languages.DFS(e[l], t, l, r)) : ((r[n.util.objId(e[l])] = !0), n.languages.DFS(e[l], t, null, r))); }, }, plugins: {}, highlightAll: function (e, t) { n.highlightAllUnder(document, e, t); }, highlightAllUnder: function (e, t, a) { var r = { callback: a, selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code', }; n.hooks.run('before-highlightall', r); for (var l, i = r.elements || e.querySelectorAll(r.selector), o = 0; (l = i[o++]); ) n.highlightElement(l, t === !0, r.callback); }, highlightElement: function (t, a, r) { for (var l, i, o = t; o && !e.test(o.className); ) o = o.parentNode; o && ((l = (o.className.match(e) || [, ''])[1].toLowerCase()), (i = n.languages[l])), (t.className = t.className.replace(e, '').replace(/\s+/g, ' ') + ' language-' + l), t.parentNode && ((o = t.parentNode), /pre/i.test(o.nodeName) && (o.className = o.className.replace(e, '').replace(/\s+/g, ' ') + ' language-' + l)); var s = t.textContent, u = { element: t, language: l, grammar: i, code: s }; if ((n.hooks.run('before-sanity-check', u), !u.code || !u.grammar)) return ( u.code && (n.hooks.run('before-highlight', u), (u.element.textContent = u.code), n.hooks.run('after-highlight', u)), n.hooks.run('complete', u), void 0 ); if ((n.hooks.run('before-highlight', u), a && _self.Worker)) { var g = new Worker(n.filename); (g.onmessage = function (e) { (u.highlightedCode = e.data), n.hooks.run('before-insert', u), (u.element.innerHTML = u.highlightedCode), n.hooks.run('after-highlight', u), n.hooks.run('complete', u), r && r.call(u.element); }), g.postMessage(JSON.stringify({ language: u.language, code: u.code, immediateClose: !0 })); } else (u.highlightedCode = n.highlight(u.code, u.grammar, u.language)), n.hooks.run('before-insert', u), (u.element.innerHTML = u.highlightedCode), n.hooks.run('after-highlight', u), n.hooks.run('complete', u), r && r.call(t); }, highlight: function (e, t, r) { var l = { code: e, grammar: t, language: r }; return ( n.hooks.run('before-tokenize', l), (l.tokens = n.tokenize(l.code, l.grammar)), n.hooks.run('after-tokenize', l), a.stringify(n.util.encode(l.tokens), l.language) ); }, matchGrammar: function (e, t, a, r, l, i, o) { var s = n.Token; for (var u in a) if (a.hasOwnProperty(u) && a[u]) { if (u == o) return; var g = a[u]; g = 'Array' === n.util.type(g) ? g : [g]; for (var c = 0; c < g.length; ++c) { var h = g[c], f = h.inside, d = !!h.lookbehind, m = !!h.greedy, p = 0, y = h.alias; if (m && !h.pattern.global) { var v = h.pattern.toString().match(/[imuy]*$/)[0]; h.pattern = RegExp(h.pattern.source, v + 'g'); } h = h.pattern || h; for (var b = r, k = l; b < t.length; k += t[b].length, ++b) { var w = t[b]; if (t.length > e.length) return; if (!(w instanceof s)) { if (m && b != t.length - 1) { h.lastIndex = k; var _ = h.exec(e); if (!_) break; for ( var j = _.index + (d ? _[1].length : 0), P = _.index + _[0].length, A = b, x = k, O = t.length; O > A && (P > x || (!t[A].type && !t[A - 1].greedy)); ++A ) (x += t[A].length), j >= x && (++b, (k = x)); if (t[b] instanceof s) continue; (I = A - b), (w = e.slice(k, x)), (_.index -= k); } else { h.lastIndex = 0; var _ = h.exec(w), I = 1; } if (_) { d && (p = _[1] ? _[1].length : 0); var j = _.index + p, _ = _[0].slice(p), P = j + _.length, N = w.slice(0, j), S = w.slice(P), C = [b, I]; N && (++b, (k += N.length), C.push(N)); var E = new s(u, f ? n.tokenize(_, f) : _, y, _, m); if ( (C.push(E), S && C.push(S), Array.prototype.splice.apply(t, C), 1 != I && n.matchGrammar(e, t, a, b, k, !0, u), i) ) break; } else if (i) break; } } } } }, tokenize: function (e, t) { var a = [e], r = t.rest; if (r) { for (var l in r) t[l] = r[l]; delete t.rest; } return n.matchGrammar(e, a, t, 0, 0, !1), a; }, hooks: { all: {}, add: function (e, t) { var a = n.hooks.all; (a[e] = a[e] || []), a[e].push(t); }, run: function (e, t) { var a = n.hooks.all[e]; if (a && a.length) for (var r, l = 0; (r = a[l++]); ) r(t); }, }, }), a = (n.Token = function (e, t, n, a, r) { (this.type = e), (this.content = t), (this.alias = n), (this.length = 0 | (a || '').length), (this.greedy = !!r); }); if ( ((a.stringify = function (e, t, r) { if ('string' == typeof e) return e; if ('Array' === n.util.type(e)) return e .map(function (n) { return a.stringify(n, t, e); }) .join(''); var l = { type: e.type, content: a.stringify(e.content, t, r), tag: 'span', classes: ['token', e.type], attributes: {}, language: t, parent: r, }; if (e.alias) { var i = 'Array' === n.util.type(e.alias) ? e.alias : [e.alias]; Array.prototype.push.apply(l.classes, i); } n.hooks.run('wrap', l); var o = Object.keys(l.attributes) .map(function (e) { return e + '="' + (l.attributes[e] || '').replace(/"/g, '&quot;') + '"'; }) .join(' '); return ( '<' + l.tag + ' class="' + l.classes.join(' ') + '"' + (o ? ' ' + o : '') + '>' + l.content + '</' + l.tag + '>' ); }), !_self.document) ) return _self.addEventListener ? (n.disableWorkerMessageHandler || _self.addEventListener( 'message', function (e) { var t = JSON.parse(e.data), a = t.language, r = t.code, l = t.immediateClose; _self.postMessage(n.highlight(r, n.languages[a], a)), l && _self.close(); }, !1 ), _self.Prism) : _self.Prism; var r = document.currentScript || [].slice.call(document.getElementsByTagName('script')).pop(); return ( r && ((n.filename = r.src), n.manual || r.hasAttribute('data-manual') || ('loading' !== document.readyState ? window.requestAnimationFrame ? window.requestAnimationFrame(n.highlightAll) : window.setTimeout(n.highlightAll, 16) : document.addEventListener('DOMContentLoaded', n.highlightAll))), _self.Prism ); })(); 'undefined' != typeof module && module.exports && (module.exports = Prism), 'undefined' != typeof global && (global.Prism = Prism); (Prism.languages.markup = { comment: /<!--[\s\S]*?-->/, prolog: /<\?[\s\S]+?\?>/, doctype: /<!DOCTYPE[\s\S]+?>/i, cdata: /<!\[CDATA\[[\s\S]*?]]>/i, tag: { pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+))?)*\s*\/?>/i, greedy: !0, inside: { tag: { pattern: /^<\/?[^\s>\/]+/i, inside: { punctuation: /^<\/?/, namespace: /^[^\s>\/:]+:/ } }, 'attr-value': { pattern: /=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+)/i, inside: { punctuation: [/^=/, { pattern: /(^|[^\\])["']/, lookbehind: !0 }] }, }, punctuation: /\/?>/, 'attr-name': { pattern: /[^\s>\/]+/, inside: { namespace: /^[^\s>\/:]+:/ } }, }, }, entity: /&#?[\da-z]{1,8};/i, }), (Prism.languages.markup.tag.inside['attr-value'].inside.entity = Prism.languages.markup.entity), Prism.hooks.add('wrap', function (a) { 'entity' === a.type && (a.attributes.title = a.content.replace(/&amp;/, '&')); }), (Prism.languages.xml = Prism.languages.markup), (Prism.languages.html = Prism.languages.markup), (Prism.languages.mathml = Prism.languages.markup), (Prism.languages.svg = Prism.languages.markup); (Prism.languages.css = { comment: /\/\*[\s\S]*?\*\//, atrule: { pattern: /@[\w-]+?[\s\S]*?(?:;|(?=\s*\{))/i, inside: { rule: /@[\w-]+/ } }, url: /url\((?:(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|.*?)\)/i, selector: /[^{}\s][^{};]*?(?=\s*\{)/, string: { pattern: /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, greedy: !0 }, property: /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i, important: /!important\b/i, function: /[-a-z0-9]+(?=\()/i, punctuation: /[(){};:,]/, }), (Prism.languages.css.atrule.inside.rest = Prism.languages.css), Prism.languages.markup && (Prism.languages.insertBefore('markup', 'tag', { style: { pattern: /(<style[\s\S]*?>)[\s\S]*?(?=<\/style>)/i, lookbehind: !0, inside: Prism.languages.css, alias: 'language-css', greedy: !0, }, }), Prism.languages.insertBefore( 'inside', 'attr-value', { 'style-attr': { pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i, inside: { 'attr-name': { pattern: /^\s*style/i, inside: Prism.languages.markup.tag.inside }, punctuation: /^\s*=\s*['"]|['"]\s*$/, 'attr-value': { pattern: /.+/i, inside: Prism.languages.css }, }, alias: 'language-css', }, }, Prism.languages.markup.tag )); Prism.languages.clike = { comment: [ { pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, lookbehind: !0 }, { pattern: /(^|[^\\:])\/\/.*/, lookbehind: !0, greedy: !0 }, ], string: { pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, greedy: !0 }, 'class-name': { pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[\w.\\]+/i, lookbehind: !0, inside: { punctuation: /[.\\]/ }, }, keyword: /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/, boolean: /\b(?:true|false)\b/, function: /\w+(?=\()/, number: /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i, operator: /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/, punctuation: /[{}[\];(),.:]/, }; (Prism.languages.javascript = Prism.languages.extend('clike', { 'class-name': [ Prism.languages.clike['class-name'], { pattern: /(^|[^$\w\xA0-\uFFFF])[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/, lookbehind: !0, }, ], keyword: [ { pattern: /((?:^|})\s*)(?:catch|finally)\b/, lookbehind: !0 }, /\b(?:as|async|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/, ], number: /\b(?:(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+)n?|\d+n|NaN|Infinity)\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/, function: /[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*\(|\.(?:apply|bind|call)\()/, operator: /-[-=]?|\+[+=]?|!=?=?|<<?=?|>>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/, })), (Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/), Prism.languages.insertBefore('javascript', 'keyword', { regex: { pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^\/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})\]]))/, lookbehind: !0, greedy: !0, }, 'function-variable': { pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\([^()]*\)|[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/i, alias: 'function', }, parameter: [ { pattern: /(function(?:\s+[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)?\s*\(\s*)[^\s()][^()]*?(?=\s*\))/, lookbehind: !0, inside: Prism.languages.javascript, }, { pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=>)/, inside: Prism.languages.javascript }, { pattern: /(\(\s*)[^\s()][^()]*?(?=\s*\)\s*=>)/, lookbehind: !0, inside: Prism.languages.javascript }, { pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\s*)\(\s*)[^\s()][^()]*?(?=\s*\)\s*\{)/, lookbehind: !0, inside: Prism.languages.javascript, }, ], constant: /\b[A-Z][A-Z\d_]*\b/, }), Prism.languages.insertBefore('javascript', 'string', { 'template-string': { pattern: /`(?:\\[\s\S]|\${[^}]+}|[^\\`])*`/, greedy: !0, inside: { interpolation: { pattern: /\${[^}]+}/, inside: { 'interpolation-punctuation': { pattern: /^\${|}$/, alias: 'punctuation' }, rest: Prism.languages.javascript, }, }, string: /[\s\S]+/, }, }, }), Prism.languages.markup && Prism.languages.insertBefore('markup', 'tag', { script: { pattern: /(<script[\s\S]*?>)[\s\S]*?(?=<\/script>)/i, lookbehind: !0, inside: Prism.languages.javascript, alias: 'language-javascript', greedy: !0, }, }), (Prism.languages.js = Prism.languages.javascript); !(function () { 'undefined' != typeof self && self.Prism && self.document && document.createRange && ((Prism.plugins.KeepMarkup = !0), Prism.hooks.add('before-highlight', function (e) { if (e.element.children.length) { var n = 0, o = [], t = function (e, d) { var r = {}; d || ((r.clone = e.cloneNode(!1)), (r.posOpen = n), o.push(r)); for (var a = 0, s = e.childNodes.length; s > a; a++) { var l = e.childNodes[a]; 1 === l.nodeType ? t(l) : 3 === l.nodeType && (n += l.data.length); } d || (r.posClose = n); }; t(e.element, !0), o && o.length && (e.keepMarkup = o); } }), Prism.hooks.add('after-highlight', function (e) { if (e.keepMarkup && e.keepMarkup.length) { var n = function (e, o) { for (var t = 0, d = e.childNodes.length; d > t; t++) { var r = e.childNodes[t]; if (1 === r.nodeType) { if (!n(r, o)) return !1; } else 3 === r.nodeType && (!o.nodeStart && o.pos + r.data.length > o.node.posOpen && ((o.nodeStart = r), (o.nodeStartPos = o.node.posOpen - o.pos)), o.nodeStart && o.pos + r.data.length >= o.node.posClose && ((o.nodeEnd = r), (o.nodeEndPos = o.node.posClose - o.pos)), (o.pos += r.data.length)); if (o.nodeStart && o.nodeEnd) { var a = document.createRange(); return ( a.setStart(o.nodeStart, o.nodeStartPos), a.setEnd(o.nodeEnd, o.nodeEndPos), o.node.clone.appendChild(a.extractContents()), a.insertNode(o.node.clone), a.detach(), !1 ); } } return !0; }; e.keepMarkup.forEach(function (o) { n(e.element, { node: o, pos: 0 }); }), (e.highlightedCode = e.element.innerHTML); } })); })();
4,505
0
petrpan-code/ProtonMail/WebClients/applications/storybook
petrpan-code/ProtonMail/WebClients/applications/storybook/.storybook/theme.js
import { create } from '@storybook/theming/create'; export default create({ base: 'light', // UI appBg: '#fafafa', appContentBg: 'white', appBorderColor: 'lightgray', appBorderRadius: 8, colorPrimary: '#6d4aff', colorSecondary: '#6d4aff', colorHover: 'red', // // Typography fontBase: '-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif', fontCode: 'SFMono-Regular, Consolas, "Liberation Mono", "Menlo", monospace, monospace', brandTitle: 'Proton Design System', brandUrl: '/', /* brandImage: 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgOTIuNSAxNS4xIiBjbGFzcz0ibG9nbyIgYXJpYS1sYWJlbGxlZGJ5PSJsb2dvX190aXRsZSI+PGc+PHBhdGggZD0iTTE5LjUsMy43aC0zdjExLjFoMS45di0zLjloMS4xYzEuMSwwLjEsMi4yLTAuMiwzLjEtMC45czEuMy0xLjcsMS4zLTIuOEMyMy45LDUsMjIuMywzLjcsMTkuNSwzLjd6IE0xOC40LDUuM2gxLjFjMS42LDAsMi40LDAuNiwyLjQsMkMyMiw3LjksMjEuNyw4LjUsMjEuMyw5Yy0wLjUsMC4zLTEuMiwwLjUtMS44LDAuNGgtMS4xVjUuM3oiPjwvcGF0aD48cGF0aCBkPSJNMjkuMiw2Yy0wLjksMC0xLjYsMC41LTIsMS4ybC0wLjEtMS4xaC0xLjZ2OC42aDEuOVYxMGMwLjMtMS41LDAuOC0yLjEsMS43LTIuMWMwLjIsMCwwLjQsMCwwLjcsMC4xaDAuMWwwLjMtMS44SDMwQzI5LjgsNi4xLDI5LjUsNiwyOS4yLDZ6Ij48L3BhdGg+PHBhdGggZD0iTTM0LjYsNmMtMS4xLDAtMi4yLDAuNC0yLjksMS4zYy0xLjMsMS45LTEuMyw0LjUsMCw2LjVjMS41LDEuNiwzLjksMS43LDUuNSwwLjJjMC4xLTAuMSwwLjItMC4yLDAuMi0wLjJjMS4zLTEuOSwxLjMtNC41LDAtNi41QzM2LjcsNi41LDM1LjcsNiwzNC42LDZ6IE0zNC41LDEzLjVjLTEuMywwLTEuOS0xLTEuOS0yLjljLTAuMS0wLjgsMC4xLTEuNiwwLjUtMi4zYzAuMy0wLjUsMC44LTAuNywxLjQtMC43YzAuNSwwLDEuMSwwLjIsMS40LDAuN2MwLjQsMC43LDAuNiwxLjUsMC41LDIuMkMzNi40LDEyLjUsMzUuOCwxMy41LDM0LjUsMTMuNXoiPjwvcGF0aD48cGF0aCBkPSJNNDQsMTMuMWMtMC4zLDAuMi0wLjYsMC4zLTEsMC4zYy0wLjUsMC0wLjgtMC4yLTAuOC0xVjcuOEg0NGwwLjItMS41aC0ydi0ybC0xLjksMC4ydjEuOEgzOXYxLjVoMS40djQuN2MwLDAuNywwLjIsMS40LDAuNiwxLjljMC41LDAuNSwxLjEsMC43LDEuOCwwLjdzMS40LTAuMiwyLTAuNmwwLjItMC4xTDQ0LjIsMTNMNDQsMTMuMXoiPjwvcGF0aD48cGF0aCBkPSJNNDkuMSw2Yy0xLjEsMC0yLjIsMC40LTIuOSwxLjNjLTEuMywxLjktMS4zLDQuNSwwLDYuNWMxLjUsMS42LDMuOSwxLjcsNS41LDAuMmMwLjEtMC4xLDAuMi0wLjIsMC4yLTAuMmMxLjMtMS45LDEuMy00LjUsMC02LjVDNTEuMiw2LjUsNTAuMiw2LDQ5LjEsNnogTTQ5LjEsMTMuNWMtMS4zLDAtMS45LTEtMS45LTIuOWMtMC4xLTAuOCwwLjEtMS42LDAuNS0yLjNjMC4zLTAuNSwwLjgtMC43LDEuNC0wLjdjMC41LDAsMS4xLDAuMiwxLjQsMC43QzUwLjgsOSw1MSw5LjcsNTEsMTAuNUM1MSwxMi41LDUwLjMsMTMuNSw0OS4xLDEzLjV6Ij48L3BhdGg+PHBhdGggZD0iTTU4LjksNmMtMC41LDAtMS4xLDAuMS0xLjUsMC40Yy0wLjMsMC4yLTAuNiwwLjQtMC44LDAuNmwtMC4xLTAuOWgtMS42djguNmgxLjl2LTZjMC42LTAuOSwxLjEtMS4zLDEuOS0xLjNjMC42LDAsMS4xLDAuMiwxLjEsMS40djUuOWgxLjlWOC44YzAtMC43LTAuMi0xLjQtMC43LTJDNjAuMyw2LjMsNTkuNiw2LDU4LjksNnoiPjwvcGF0aD48cGF0aCBkPSJNNzAuOCwzLjdsLTIsNy4ybC0yLjEtNy4yaC0yLjNsLTAuOSwxMS4xaDEuOGwwLjQtNC45YzAuMS0xLjEsMC4xLTIuMiwwLjItMy4ybDIuMSw2LjloMS43bDItNi45YzAsMC45LDAuMSwyLDAuMiwzLjFsMC40LDVoMS45TDczLjEsMy43SDcwLjh6Ij48L3BhdGg+PHBhdGggZD0iTTgyLjMsMTIuN1Y5YzAuMS0wLjgtMC4yLTEuNi0wLjgtMi4yQzgwLjksNi4zLDgwLDYsNzkuMiw2Yy0xLDAtMiwwLjItMi45LDAuNmwtMC4yLDAuMWwwLjUsMS40TDc2LjgsOGMwLjctMC4zLDEuNC0wLjQsMi4xLTAuNEM4MCw3LjYsODAuNCw4LDgwLjQsOXYwLjRoLTFjLTEtMC4xLTIsMC4yLTIuOCwwLjdjLTEuMiwxLTEuNCwyLjgtMC40LDRsMC4xLDAuMWMwLjYsMC41LDEuMywwLjgsMi4xLDAuN2MwLjksMCwxLjgtMC4zLDIuNC0xYzAuMywwLjYsMC45LDEsMS42LDFoMC4ybDAuNC0xLjRsLTAuMi0wLjFDODIuNSwxMy41LDgyLjMsMTMuNCw4Mi4zLDEyLjd6IE03OC43LDEzLjVjLTAuOCwwLTEuMi0wLjQtMS4yLTEuM2MwLTAuNCwwLjEtMC44LDAuNS0xLjFjMC41LTAuMywxLTAuNCwxLjYtMC40aDAuOXYxLjZDODAuMSwxMy4xLDc5LjQsMTMuNSw3OC43LDEzLjVMNzguNywxMy41eiI+PC9wYXRoPjxwYXRoIGQ9Ik04NS43LDIuM2MtMC43LDAtMS4yLDAuNS0xLjIsMS4yYzAsMC4zLDAuMSwwLjYsMC4zLDAuOGMwLjIsMC4yLDAuNSwwLjMsMC45LDAuM2MwLjcsMCwxLjItMC41LDEuMi0xLjFTODYuNCwyLjMsODUuNywyLjNMODUuNywyLjN6Ij48L3BhdGg+PHJlY3QgeD0iODQuOCIgeT0iNi4yIiB3aWR0aD0iMS45IiBoZWlnaHQ9IjguNiI+PC9yZWN0PjxwYXRoIGQ9Ik05MS45LDEzLjNsLTAuMiwwLjFjLTAuMSwwLjEtMC4zLDAuMS0wLjQsMC4xcy0wLjMsMC0wLjMtMC40VjIuN0w4OS4xLDN2MTBjLTAuMSwxLDAuNSwxLjksMS41LDJjMC4xLDAsMC4yLDAsMC40LDBjMC41LDAsMC45LTAuMSwxLjMtMC4zbDAuMi0wLjFMOTEuOSwxMy4zeiI+PC9wYXRoPjwvZz48Zz48cGF0aCBkPSJNNS4zLDBDMi42LDAsMC4zLDIuMSwwLDQuOHYzLjNjMCwwLDAsMC40LDEsMS4xUzQuNywxMiw1LjMsMTJzMy4zLTIsNC4zLTIuOHMxLTEuMSwxLTEuMVY0LjhDMTAuMywyLjEsOC4xLDAsNS4zLDB6IE04LjQsNi42SDIuM1Y0LjhDMi42LDMuMSw0LjMsMiw2LDIuNGMxLjIsMC4yLDIuMiwxLjIsMi40LDIuNFY2LjZ6Ij48L3BhdGg+PHBhdGggZD0iTTUuMywxMi43Yy0wLjQtMC4xLTAuOS0wLjItMS4yLTAuNGMtMC41LTAuNC00LjEtMy00LjEtM3Y1LjFDMCwxNC43LDAuMywxNSwwLjcsMTVsMCwwSDEwYzAuMywwLDAuNy0wLjIsMC43LTAuNmwwLDBWOS4zYzAsMC0zLjYsMi42LTQuMSwyLjlDNi4yLDEyLjUsNS44LDEyLjcsNS4zLDEyLjd6Ij48L3BhdGg+PC9nPjx0aXRsZSBpZD0ibG9nb19fdGl0bGUiPlByb3Rvbk1haWw8L3RpdGxlPjwvc3ZnPg==', */ });
4,506
0
petrpan-code/ProtonMail/WebClients/applications/storybook
petrpan-code/ProtonMail/WebClients/applications/storybook/scripts/changelog.sh
#!/usr/bin/env bash set -eo pipefail git fetch origin main:main git checkout main # PARENT_DIR relative to location of script of file system PARENT_DIR="$(dirname "${BASH_SOURCE[0]}")" cd "$PARENT_DIR"/.. # Notice the "." at the end # We're taking the latest merge commit that affected the current directory # We're skipping one of the merge commits since this script is intended to # trigger on a merge into the main branch and we don't want to compare with # the commit that triggered the script to run in the first place. LATEST_MERGE_COMMIT="$(git log --full-history --skip 1 --merges -n 1 --pretty=format:%H .)" echo "SHA of latest merge commit: $LATEST_MERGE_COMMIT" DIFF="$(git diff "$LATEST_MERGE_COMMIT" HEAD CHANGELOG.md || true)" if ! [[ "$DIFF" =~ ^diff ]]; then echo "No new changelog diffs between latest merge commit and now" exit 0 fi TEXT="$(git diff "$LATEST_MERGE_COMMIT" HEAD CHANGELOG.md | grep -E "^\+" | sed -e 's/^\+//' | tail -n +2 | node scripts/format)" echo "Changelog contains new entries \n\n$TEXT" curl -X POST -H 'Content-type: application/json' --data "{ \"text\": $TEXT }" "${SLACK_WEBHOOK_URL}"
4,507
0
petrpan-code/ProtonMail/WebClients/applications/storybook
petrpan-code/ProtonMail/WebClients/applications/storybook/scripts/format
const fs = require('fs'); const data = fs.readFileSync('/dev/stdin', 'utf-8'); const message = 'New changelog entries:' + '\n' + `\n>${data.replace(/\n/g, '\n>')}` + '\n' + '\n<https://design-system.protontech.ch/|documentation> | <https://design-system.protontech.ch/?path=/docs/changelog--page|changelog>' console.log(JSON.stringify(message));
4,508
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src
petrpan-code/ProtonMail/WebClients/applications/storybook/src/app/index.scss
@import '~@proton/colors/themes/dist/duotone.theme.css'; @import '~@proton/styles/scss/proton-ui-storybook'; body { overflow: scroll !important; color: inherit; } pre code { line-height: 1.5 !important; } // dirty fixes while whaiting to have better solutions .language-markup code { inline-size: 100%; white-space: pre-wrap; } .icon-ko, .icon-ok { &::after { position: absolute; inset-block-start: 0.75em; inset-inline-end: 0; padding-block: 0; padding-inline: 0 0.5em; font-size: 2em; } } .icon-ko::after { content: '×'; color: var(--signal-danger); } .icon-ok::after { content: '✔'; color: var(--signal-success); } .icon-ko button { display: none; // don't copy shit! } table { // table-layout: initial; &.no-bg { tr { background: none !important; } } } .sbdocs-h2 { margin-block-start: 2em !important; border: none !important; } // Fix weird margin on auto scroll .docs-story > div { margin: 0; } .icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1em; } .sbdocs-a { &#{&} { @extend .link; color: var(--link-norm) !important; } } // Theme support .sbdocs:not(.bg-primary) { background: var(--background-norm) !important; color: var(--text-norm) !important; } .sbdocs-title { color: var(--text-norm) !important; } .sbdocs-preview { border-color: var(--border-weak) !important; } .docblock-code-toggle { background: var(--background-strong) !important; color: var(--text-norm) !important; border-color: var(--border-weak) !important; } .docs-story > div:last-child { background: none !important; } .sbdocs-preview > .os-host { background: var(--background-strong) !important; border: none !important; box-shadow: none !important; button, a { color: var(--text-norm) !important; } } .docblock-source { color: black !important; background: white !important; border-color: var(--border-weak) !important; .prismjs { background: white !important; } } .docblock-argstable-head { background: var(--background-strong) !important; th { color: var(--text-norm) !important; } } .docblock-argstable-body { border: none !important; tr { border-color: var(--border-weak) !important; } td { background: var(--background-weak) !important; color: var(--text-weak) !important; } } .docblock-emptyblock { color: var(--text-weak) !important; border-color: var(--border-weak) !important; } // props content when multiple tabs are shown #panel-tab-content { background: none !important; } .docblock-colorpalette div { color: var(--text-norm) !important; } .docblock-colorpalette [title^='var(--'] { padding-block: 0; padding-inline: 0.1rem; font-size: 0.8em; user-select: all; } body.sb-main-fullscreen::before { position: fixed; inset-block-end: 0; display: block; background: var(--primary); color: var(--primary-contrast); border-radius: var(--border-radius-sm); font-size: 0.8em; padding-block: 0; padding-inline: 0.3em; inset-inline-end: 0; z-index: 12000; }
4,509
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src
petrpan-code/ProtonMail/WebClients/applications/storybook/src/app/index.tsx
// Dummy file needed for proton-pack
4,510
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/assets
petrpan-code/ProtonMail/WebClients/applications/storybook/src/assets/favicons/favicon.svg
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M2.875 11.3383V14.9783H5.43V11.4962C5.43 11.1573 5.5646 10.8324 5.80417 10.5928C6.04375 10.3532 6.36869 10.2187 6.7075 10.2187H9.32726C9.93252 10.2187 10.5319 10.0994 11.091 9.8678C11.6502 9.63616 12.1583 9.29665 12.5863 8.86864C13.0143 8.44064 13.3537 7.93254 13.5853 7.37333C13.8169 6.81413 13.9361 6.21477 13.9361 5.60951C13.9361 5.00421 13.817 4.40482 13.5854 3.84558C13.3539 3.28633 13.0144 2.77819 12.5864 2.35015C12.1584 1.92211 11.6503 1.58256 11.0911 1.35091C10.5319 1.11925 9.93255 1 9.32726 1H2.875V5.55H5.43V3.40451H9.15436C9.73269 3.40451 10.2873 3.63422 10.6963 4.04314C11.1053 4.45205 11.3351 5.00666 11.3352 5.585C11.3352 6.1634 11.1054 6.71811 10.6965 7.1271C10.2875 7.53609 9.73275 7.76585 9.15436 7.76585H6.4464C5.97726 7.76567 5.51269 7.85796 5.07923 8.03744C4.64578 8.21692 4.25194 8.48007 3.92026 8.81185C3.58857 9.14364 3.32554 9.53755 3.14618 9.97106C2.96683 10.4046 2.87468 10.8692 2.875 11.3383Z" fill="url(#paint0_radial_22658_223100)" /> <path d="M6.7068 10.2183C6.20359 10.2182 5.7053 10.3173 5.24038 10.5098C4.77546 10.7024 4.35304 10.9846 3.99721 11.3405C3.64139 11.6963 3.35914 12.1187 3.16659 12.5836C2.97404 13.0485 2.87495 13.5468 2.875 14.0501V14.9779H5.43V11.4958C5.43 11.1571 5.5645 10.8322 5.80393 10.5927C6.04335 10.3531 6.36811 10.2184 6.7068 10.2183V10.2183Z" fill="url(#paint1_linear_22658_223100)" /> <defs> <radialGradient id="paint0_radial_22658_223100" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(13.9753 -0.940752) scale(14.069 14.069)" > <stop stop-color="#FF9CBD" /> <stop offset="1" stop-color="#FF4785" /> </radialGradient> <linearGradient id="paint1_linear_22658_223100" x1="4.7909" y1="14.2895" x2="4.7909" y2="8.94076" gradientUnits="userSpaceOnUse" > <stop stop-color="#FF4785" /> <stop offset="1" stop-color="#991441" /> </linearGradient> </defs> </svg>
4,511
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src
petrpan-code/ProtonMail/WebClients/applications/storybook/src/helpers/title.ts
import _startcase from 'lodash.startcase'; const caseString = (str: string, caseFilename: boolean = true) => { // avoid _startcase stripping the '/' return str .split('/') .map((item, index, arr) => { if (!caseFilename && index === arr.length - 1) { return item; } return _startcase(item); }) .join('/'); }; export const getTitle = (filename: string, caseFilename?: boolean) => { const directoryPrefix = 'src/stories/'; const storySuffix = /.stories.(tsx|mdx)/; const strippedFileName = filename.replace(directoryPrefix, '').replace(storySuffix, ''); return caseString(strippedFileName, caseFilename); };
4,512
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/Changelog.stories.mdx
import { Description, Meta } from '@storybook/addon-docs'; import changelog from '../../CHANGELOG.md'; import { getTitle } from '../helpers/title'; <Meta title={getTitle(__filename)} /> <Description>{changelog}</Description>
4,513
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/Introduction.stories.mdx
import { Description, Meta } from '@storybook/addon-docs'; import readme from '../../README.md'; import { getTitle } from '../helpers/title'; <Meta title={getTitle(__filename)} /> <Description>{readme}</Description>
4,514
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Alert.mdx
import { ArgsTable, Canvas, PRIMARY_STORY, Primary, Story } from '@storybook/addon-docs'; import { Alert } from '@proton/components'; # Alert The Alert component is used to display different inline alerts across the Proton app suite <Canvas withSource="open"> <Story id="components-alert--basic" /> </Canvas> ### Types <Canvas> <Story id="components-alert--types" /> </Canvas> ### Learn More Link <Canvas> <Story id="components-alert--learn-more-link" /> </Canvas> ### Props <div class="hidden"> <Primary /> </div> <ArgsTable story={PRIMARY_STORY} />
4,515
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Alert.stories.tsx
import { Alert } from '@proton/components'; import { getTitle } from '../../helpers/title'; import mdx from './Alert.mdx'; export default { component: Alert, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; export const Basic = () => ( <Alert> Lorem Ipsum dolor sit amet consectetur adipisicing elit. Praesentium unde, blanditiis rem accusamus obcaecati enim amet, voluptatibus nemo facilis illum aut itaque in? Deleniti iure amet qui vero, blanditiis quos? </Alert> ); export const Types = () => ( <> <Alert className="mb-4"> Lorem ipsum dolor sit amet consectetur adipisicing elit. Praesentium unde, blanditiis rem accusamus obcaecati enim amet, voluptatibus nemo facilis illum aut itaque in? Deleniti iure amet qui vero, blanditiis quos? </Alert> <Alert className="mb-4" type="error"> Lorem ipsum dolor sit amet consectetur adipisicing elit. Nemo corporis ea nobis nesciunt sed sit architecto atque. Vero, corrupti non nobis, officia blanditiis magnam ex sapiente et expedita, animi tenetur! </Alert> <Alert className="mb-4" type="warning"> Lorem ipsum, dolor sit amet consectetur adipisicing elit. Maiores tempora ea eos corporis facilis facere, nemo sunt. Eos, blanditiis laboriosam expedita voluptatem eaque vero esse, minima temporibus, ab ad nesciunt? </Alert> <Alert className="mb-4" type="success"> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sit doloribus nobis eos iusto. Ducimus numquam laborum aliquid culpa! Dolor voluptatem modi inventore error, qui repudiandae consequatur autem vitae illum voluptatibus? </Alert> </> );
4,516
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Autocomplete.mdx
import { ArgsTable, Canvas, Primary, Story } from '@storybook/addon-docs'; import { Autocomplete } from '@proton/components'; # Autocomplete The Autocomplete component is a more complex variant of a text input. This component allows a user to select a value from a list of options by suggesting options based on what text the user types into an input field. Technically, this is a wrapper around `Dropdown` together with `Option`s proving autocomplete functionality & exposing it via a generic autocomplete component and lower-level hooks. <Canvas withSource="open"> <Story id="components-autocomplete--basic" /> </Canvas> ### Simple There is a convenience variant of the Autocomplete called `SimpleAutocomplete` which wraps the `Autocomplete` component, providing it with a sensible default configuration, mainly assuming that the options array input will consist of strings only. <Canvas> <Story id="components-autocomplete--simple" /> </Canvas> ### Hooks API The Autocomplete component tries to achieve flexibility for different types of input collection & rendering use-cases with lower-level hooks. The hook api returns props to spread on the input and option elements. <Canvas> <Story id="components-autocomplete--custom" /> </Canvas> ### Accessibility Since this is a component where focus persists inside the anchor even while keyboard navigating through the elements inside its dropdown, accessibility can't be managed via native focus and has to be artifically created via aria attributes. It is for that reason that the `id` prop, which is used internally to link the dropdown contents to it's anchor, is required. ### Props <div class="hidden"> <Primary /> </div> <ArgsTable of={Autocomplete} />
4,517
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Autocomplete.stories.tsx
import { useRef, useState } from 'react'; import { Autocomplete, AutocompleteList, Icon, IconName, Input, Marks, Option, SimpleAutocomplete, useAutocomplete, useAutocompleteFilter, } from '@proton/components'; import { getTitle } from '../../helpers/title'; import mdx from './Autocomplete.mdx'; export default { title: getTitle(__filename, false), component: Autocomplete, parameters: { docs: { page: mdx, }, }, }; export const Basic = () => { const [value, setValue] = useState(''); const options = [ { value: 'henlo', label: 'Henló' }, { value: 'schmenlo', label: 'Schmenlo' }, { value: 'benlo', label: 'Benlo' }, { value: 'frenlo', label: 'Frenlo' }, { value: 'menlo', label: 'Ménlo' }, ]; return ( <Autocomplete id="autocomplete" value={value} onChange={setValue} onSelect={({ label }) => setValue(label)} placeholder="Example" options={options} getData={({ label }) => label} /> ); }; export const Simple = () => { const options = [ 'henlo', 'benlo', 'schmenlo', 'henlo and benlo', 'benlo and schmenlo', 'schmenlo and schmenlo', 'renlo', 'kenlo', 'schmenlo', 'henlo and kenlo', 'lenlo and schmenlo', 'achmenlo and lchmenlo', ]; const [value, setValue] = useState(options[0]); return <SimpleAutocomplete id="autocomplete" value={value} options={options} onChange={setValue} />; }; interface ServiceOption { value: string; label: string; icon: IconName; } export const Custom = () => { const [value, setValue] = useState(''); const containerRef = useRef<HTMLInputElement>(null); const inputRef = useRef<HTMLInputElement>(null); const options = (['brand-android', 'brand-apple', 'brand-chrome', 'brand-linux'] as const).map((service) => { return { value: service, label: service.charAt(0).toUpperCase() + service.slice(1), icon: service, }; }); const getData = ({ label }: ServiceOption) => label; const filteredOptions = useAutocompleteFilter(value, options, getData, 20, 0); const handleSelect = (optionValue: ServiceOption) => { setValue(optionValue.label); }; const { onClose, getOptionID, inputProps, suggestionProps } = useAutocomplete({ id: 'autocomplete', options: filteredOptions, onSelect: handleSelect, input: value, inputRef, }); const handleSelectOption = (optionValue: ServiceOption) => { handleSelect(optionValue); onClose(); }; return ( <> <Input {...inputProps} placeholder="Service" ref={inputRef} containerRef={containerRef} value={value} onChange={(event) => { setValue(event.currentTarget.value.trimStart()); }} /> <AutocompleteList anchorRef={containerRef.current ? containerRef : inputRef} {...suggestionProps}> {filteredOptions.map(({ chunks, text, option }, index) => { return ( <Option key={text} id={getOptionID(index)} title={text} value={option} disableFocusOnActive onChange={handleSelectOption} > <Icon name={option.icon} /> <Marks chunks={chunks}>{text}</Marks> ({index}) </Option> ); })} </AutocompleteList> </> ); };
4,518
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Badge.mdx
import { ArgsTable, Canvas, PRIMARY_STORY, Preview, Primary, Story } from '@storybook/addon-docs'; import { Badge } from '@proton/components'; # Badge <Canvas withSource="open"> <Story id="components-badge--basic" /> </Canvas> ### Colors The Badge support the status colors of the design system through the `type` prop. <Canvas> <Story id="components-badge--colors" /> </Canvas> ### With tooltip By using `tooltip` prop, you can attach a tooltip to it. <Canvas> <Story id="components-badge--with-tooltip" /> </Canvas> ### Props <div class="hidden"> <Primary /> </div> <ArgsTable story={PRIMARY_STORY} />
4,519
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Badge.stories.tsx
import { Badge } from '@proton/components'; import { getTitle } from '../../helpers/title'; import mdx from './Badge.mdx'; export default { component: Badge, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; export const Basic = () => <Badge type="primary">Primary</Badge>; export const Colors = () => ( <> <Badge>Badge</Badge> <Badge type="primary">Primary</Badge> <Badge type="error">Error</Badge> <Badge type="success">Success</Badge> <Badge type="origin">Origin</Badge> <Badge type="light">Origin</Badge> <Badge type="warning">Warning</Badge> </> ); export const WithClassName = () => <Badge className="text-bold">Bold</Badge>; export const WithTooltip = () => ( <Badge tooltip="Boo!" type="warning"> Hover me </Badge> );
4,520
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/ButtonGroup.mdx
import { ArgsTable, Canvas, PRIMARY_STORY, Primary, Story } from '@storybook/addon-docs'; # ButtonGroup The button group is simply a group of [Button](?path=/docs/components-button--basic) components. ## How to use <Canvas withSource="open"> <Story id="components-buttongroup--basic-group" /> </Canvas> ## Variants The ButtonGroup component demands its own `shape`, `color` and `size` parameters to adapt its embeded buttons automatically. <Story id="components-buttongroup--sandbox" /> <Story id="components-buttongroup--variants" /> ## Playground <Primary /> <ArgsTable story={PRIMARY_STORY} />
4,521
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/ButtonGroup.stories.tsx
import { useState } from 'react'; import { Button } from '@proton/atoms'; import { ButtonGroup, RadioGroup, Table, TableBody, TableCell, TableHeader, TableRow } from '@proton/components'; import { getTitle } from '../../helpers/title'; import mdx from './ButtonGroup.mdx'; export default { component: ButtonGroup, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; export const BasicGroup = ({ ...args }) => { const [selectedButton, setSelectedButton] = useState(2); const buttons = [ { text: 'Bulbasaur', }, { text: 'Another', }, { text: 'A third button', }, { text: 'How about one more', }, ]; return ( <ButtonGroup {...args}> {buttons.map(({ text }, i) => { return ( <Button key={i} selected={selectedButton === i} onClick={() => setSelectedButton(i)}> {text} </Button> ); })} </ButtonGroup> ); }; BasicGroup.args = {}; type ButtonGroupProps = React.ComponentProps<typeof ButtonGroup>; const shapes: Required<ButtonGroupProps>['shape'][] = ['solid', 'outline', 'ghost']; const colors: Required<ButtonGroupProps>['color'][] = ['norm', 'weak']; const sizes: Required<ButtonGroupProps>['size'][] = ['small', 'medium', 'large']; const buttonContainerClassName = 'flex flex-item-fluid flex-align-items-center flex-justify-center border'; export const Sandbox = () => { const [selectedShape, setSelectedShape] = useState<Required<ButtonGroupProps>['shape']>('solid'); const [selectedColor, setSelectedColor] = useState<Required<ButtonGroupProps>['color']>('weak'); const [selectedSize, setSelectedSize] = useState<Required<ButtonGroupProps>['size']>('medium'); const [selectedButton, setSelectedButton] = useState(0); const buttons = [ { text: selectedShape, }, { text: selectedColor, }, { text: selectedSize, }, ]; const buttonGroup = ( <ButtonGroup shape={selectedShape} color={selectedColor} size={selectedSize}> {buttons.map(({ text }, i) => { return ( <Button key={i} selected={selectedButton === i} onClick={() => setSelectedButton(i)}> {text} </Button> ); })} </ButtonGroup> ); return ( <div className="my-8"> <div className="flex flex-align-items-stretch"> <div className="mr-8"> <strong className="block mb-4">Color</strong> <RadioGroup name="selected-color" onChange={(v) => setSelectedColor(v)} value={selectedColor} options={colors.map((color) => ({ value: color, label: color }))} /> </div> <div className="mr-8"> <strong className="block mb-4">Shape</strong> <RadioGroup name="selected-shape" onChange={(v) => setSelectedShape(v)} value={selectedShape} options={shapes.map((shape) => ({ value: shape, label: shape }))} /> </div> <div className="mr-8"> <strong className="block mb-4">Size</strong> <RadioGroup name="selected-size" onChange={(v) => setSelectedSize(v)} value={selectedSize} options={sizes.map((size) => ({ value: size, label: size }))} /> </div> <div className={buttonContainerClassName}>{buttonGroup}</div> </div> </div> ); }; export const Variants = () => { const [selectedButton, setSelectedButton] = useState(0); const buttons = [ { text: 'Lorem', }, { text: 'Ipsum', }, ]; return ( <Table className="color-norm"> <TableHeader> <TableRow> <TableCell> <></> </TableCell> {colors.map((color) => ( <TableCell key={color} scope="col"> {color} </TableCell> ))} </TableRow> </TableHeader> <TableBody> {shapes.map((shape) => ( <TableRow key={shape}> <TableCell>{shape}</TableCell> {colors.map((color) => ( <TableCell key={color}> <ButtonGroup shape={shape} color={color}> {buttons.map(({ text }, i) => { return ( <Button key={i} selected={selectedButton === i} onClick={() => setSelectedButton(i)} > {text} </Button> ); })} </ButtonGroup> </TableCell> ))} </TableRow> ))} </TableBody> </Table> ); };
4,522
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Checkbox.mdx
import { ArgsTable, Canvas, PRIMARY_STORY, Primary, Story } from '@storybook/addon-docs'; # Checkbox Checkboxes allow the user to select one or more items from a set. <Canvas withSource="open"> <Story id="components-checkbox--basic" /> </Canvas> ## InputField The Checkbox component can be uses as an [input for InputField](/docs/components-inputfield--basic#custom-elements). <Canvas> <Story id="components-checkbox--as-input-field" /> </Canvas> ## Loading By using the `loading` prop, the interaction with the `Checkbox` component will be blocked during loading. <Canvas> <Story id="components-checkbox--loading" /> </Canvas> ## Colors The Checkbox component colors can be set using `backgroundColor`, `borderColor` and `color`, which is currently used in Calendar. <Canvas> <Story id="components-checkbox--colors" /> </Canvas> ## Indeterminate To indicate an indeterminate state of a checkbox, add the `indeterminate` prop. This is used in Drive. <Canvas> <Story id="components-checkbox--indeterminate" /> </Canvas> <div class="hidden"> <Primary /> </div> <ArgsTable story={PRIMARY_STORY} />
4,523
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Checkbox.stories.tsx
import { useState } from 'react'; import { Checkbox, InputFieldTwo } from '@proton/components'; import { useLoading } from '@proton/hooks'; import { wait } from '@proton/shared/lib/helpers/promise'; import { getTitle } from '../../helpers/title'; import mdx from './Checkbox.mdx'; export default { component: Checkbox, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; export const Basic = () => { return ( <div> Whachu wanna eat? <div className="my-4"> <Checkbox id="tofu">Tofu</Checkbox> </div> <div className="my-4"> <Checkbox id="spaghetti" checked> Spaghetti </Checkbox> </div> <div className="my-4"> <Checkbox id="upsetti" checked disabled> Upsetti </Checkbox> </div> <div className="my-4"> <Checkbox id="overflow"> Lorem ipsum dolor sit amet consectetur adipisicing elit. Praesentium unde, blanditiis rem accusamus obcaecati enim amet, voluptatibus nemo facilis illum aut itaque in? Deleniti iure amet qui vero, blanditiis quos? </Checkbox> </div> </div> ); }; export const AsInputField = () => { const [checked, setChecked] = useState(false); return <InputFieldTwo as={Checkbox} label="Checkbox" checked={checked} onChange={() => setChecked(!checked)} />; }; export const Loading = () => { const [isChecked, setIsChecked] = useState(false); const [loading, withLoading] = useLoading(false); return ( <Checkbox id="checkbox-loading" checked={isChecked} loading={loading} onChange={() => { const run = async () => { await wait(1000); setIsChecked((old) => !old); }; void withLoading(run()); }} > Tofu </Checkbox> ); }; export const Colors = () => { return ( <Checkbox id="red" backgroundColor="rgb(255, 50, 50)" borderColor="rgb(200, 80, 80)" color="rgb(255, 255, 255)"> I'm red </Checkbox> ); }; export const Indeterminate = () => { return ( <Checkbox id="Indeterminate" indeterminate> I'm Indeterminate </Checkbox> ); };
4,524
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Collapsible.mdx
import { ArgsTable, Canvas, PRIMARY_STORY, Primary, Story } from '@storybook/addon-docs'; import { Collapsible, CollapsibleContent, CollapsibleHeader } from '@proton/components'; # Collapsible The `Collapsible`, `CollapsibleHeader`, and `CollapsibleContent` components allow showing and hiding sections of related content. <Canvas withSource="open"> <Story id="components-collapsible--basic" /> </Canvas> ## Default to showing content Use `expandByDefault` to show content by default. <Canvas> <Story id="components-collapsible--expanded-by-default" /> </Canvas> ## Expand button The `CollapsibleHeader` suffix can be used to render buttons to toggle the collapsible component. <Canvas> <Story id="components-collapsible--expand-button" /> </Canvas> ## Tooltip text The tooltip text can be customised using the `expandText` and `closeText` props. <Canvas> <Story id="components-collapsible--tooltip-text" /> </Canvas> ## Full width By default the header content grows to fill space. This can be disabled using `disableFullWidth`. <Canvas> <Story id="components-collapsible--full-width" /> </Canvas> ## Togglable container By default the header is clickable. This can be disabled using `disableContainerToggle` meaning the only way to toggle the content is by using the icon. It is advised not to set this prop to `true` if there is no expand icon. <Canvas> <Story id="components-collapsible--togglable-container" /> </Canvas> ## Props <div class="hidden"> <Primary /> </div> <ArgsTable story={PRIMARY_STORY} />
4,525
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Collapsible.stories.tsx
import { Collapsible, CollapsibleContent, CollapsibleHeader, CollapsibleHeaderButton, CollapsibleHeaderIconButton, Icon } from '@proton/components'; import mdx from './Collapsible.mdx'; export default { component: Collapsible, subcomponents: { CollapsibleHeader, CollapsibleContent, CollapsibleHeaderButton, CollapsibleHeaderIconButton }, title: 'components/Collapsible', parameters: { docs: { page: mdx } }, }; export const Basic = () => ( <Collapsible> <CollapsibleHeader suffix={ <CollapsibleHeaderIconButton> <Icon name="chevron-down" /> </CollapsibleHeaderIconButton> } > Collapsible header </CollapsibleHeader> <CollapsibleContent> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </CollapsibleContent> </Collapsible> ); export const ExpandedByDefault = () => ( <Collapsible expandByDefault> <CollapsibleHeader suffix={ <CollapsibleHeaderIconButton> <Icon name="chevron-down" /> </CollapsibleHeaderIconButton> } > Collapsible header </CollapsibleHeader> <CollapsibleContent> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </CollapsibleContent> </Collapsible> ); export const ExpandButton = () => ( <> <Collapsible className="mb-4"> <CollapsibleHeader suffix={ <CollapsibleHeaderIconButton> <Icon name="chevron-down" /> </CollapsibleHeaderIconButton> } > Chevron icon </CollapsibleHeader> <CollapsibleContent> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </CollapsibleContent> </Collapsible> <Collapsible className="mb-4"> <CollapsibleHeader suffix={ <CollapsibleHeaderIconButton> <Icon name="brand-proton" /> </CollapsibleHeaderIconButton> } > Proton icon </CollapsibleHeader> <CollapsibleContent> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </CollapsibleContent> </Collapsible> <Collapsible> <CollapsibleHeader>Omitted icon</CollapsibleHeader> <CollapsibleContent> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </CollapsibleContent> </Collapsible> <Collapsible> <CollapsibleHeader suffix={<CollapsibleHeaderButton>Toggle</CollapsibleHeaderButton>}> Button </CollapsibleHeader> <CollapsibleContent> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </CollapsibleContent> </Collapsible> </> ); export const TooltipText = () => ( <Collapsible> <CollapsibleHeader suffix={ <CollapsibleHeaderIconButton expandText="I can be opened" collapseText="I can be collapsed"> <Icon name="chevron-down" /> </CollapsibleHeaderIconButton> } > Collapsible header </CollapsibleHeader> <CollapsibleContent> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </CollapsibleContent> </Collapsible> ); export const FullWidth = () => ( <Collapsible> <CollapsibleHeader suffix={ <CollapsibleHeaderIconButton> <Icon name="chevron-down" /> </CollapsibleHeaderIconButton> } disableFullWidth > Collapsible header not full width </CollapsibleHeader> <CollapsibleContent> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </CollapsibleContent> </Collapsible> ); export const TogglableContainer = () => ( <Collapsible> <CollapsibleHeader suffix={ <CollapsibleHeaderIconButton> <Icon name="chevron-down" /> </CollapsibleHeaderIconButton> } disableContainerToggle > Collapsible header not clickable </CollapsibleHeader> <CollapsibleContent> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </CollapsibleContent> </Collapsible> );
4,526
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Copy.mdx
import { ArgsTable, Canvas, Primary, Story } from '@storybook/addon-docs'; import { Copy } from '@proton/components'; # Copy Copying text to the clipboard shouldn't be hard. ### Basic `Copy` is a simple component, it renders a button to capture click and then copy a value to the clipboard. <Canvas withSource="open"> <Story id="components-copy--basic" /> </Canvas> <div class="hidden"> <Primary /> </div> <ArgsTable of={Copy} />
4,527
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Copy.stories.tsx
import { Copy } from '@proton/components'; import { getTitle } from '../../helpers/title'; import mdx from './Copy.mdx'; export default { component: Copy, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; export const Basic = () => <Copy value="Pikachu" onCopy={() => alert(`"Pikachu" copied to clipboard`)} />;
4,528
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/CountrySelect.mdx
import { ArgsTable, Canvas, PRIMARY_STORY, Primary, Story } from '@storybook/addon-docs'; import CountrySelect from '@proton/components/components/country/CountrySelect'; # CountrySelect ### Basic Display given country options in a searchable dropdown. Options are sorted by name, grouped by their first letter and a divider is added between "groups". <Canvas withSource="false"> <Story id="components-countryselect--basic" /> </Canvas> ### Playground In case you want to add a suggestion to the user, it's possible to pass an option that will be pre-selected in the input. This will add a new option displayed at the top of the dropdown. <Story id="components-countryselect--pre-select" /> ### Props <div class="hidden"> <Primary /> </div> <ArgsTable story={PRIMARY_STORY} />
4,529
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/CountrySelect.stories.tsx
import { useState } from 'react'; import { InputFieldTwo } from '@proton/components/components'; import CountrySelect from '@proton/components/components/country/CountrySelect'; import { CountryOption } from '@proton/components/components/country/helpers'; import { getTitle } from '../../helpers/title'; import mdx from './CountrySelect.mdx'; export default { component: CountrySelect, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; const options: CountryOption[] = [ { countryName: 'France', countryCode: 'fr' }, { countryName: 'Finland', countryCode: 'fi' }, { countryName: 'Australia', countryCode: 'au' }, { countryName: 'Belgium', countryCode: 'be' }, { countryName: 'Switzerland', countryCode: 'ch' }, { countryName: 'Sweden', countryCode: 'se' }, { countryName: 'Ireland', countryCode: 'ie' }, { countryName: 'Norway', countryCode: 'no' }, ]; export const Basic = () => { return <CountrySelect options={options} />; }; export const PreSelect = () => { const [preSelectedOptionDivider, setPreSelectedOptionDivider] = useState(''); const [hint, setHint] = useState(''); return ( <> <div className="flex flex-item-fluid flex-align-items-center flex-justify-center border p-7"> <CountrySelect options={options} preSelectedOption={options[0]} preSelectedOptionDivider={!!preSelectedOptionDivider ? preSelectedOptionDivider : undefined} hint={hint} /> </div> <div className="flex flex-nowrap gap-7 py-7"> <InputFieldTwo label="Divider" placeholder="Change the pre-selected option divider text" value={preSelectedOptionDivider} onValue={(value: string) => setPreSelectedOptionDivider(value)} /> <InputFieldTwo label="Hint" placeholder="Add a hint to the select" value={hint} onValue={(value: string) => setHint(value)} /> </div> </> ); };
4,530
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/DateInput.mdx
import { ArgsTable, Canvas, PRIMARY_STORY, Primary, Story } from '@storybook/addon-docs'; # DateInput ### Basic <Canvas withSource="open"> <Story id="components-dateinput--basic" /> </Canvas> ### With min and max date Use min and max properties so that the user can choose a date in the interval. He is able to choose a date outside the interval through typing but the value is reset. <Canvas> <Story id="components-dateinput--with-min-and-max" /> </Canvas> ### With min and max date and prevent value reset Use the preventValueReset property to prevent the reset of the value if <b>value < min</b> or <b>value > max</b>, so that we can display an error. <Canvas> <Story id="components-dateinput--with-min-and-max-and-preventreset" /> </Canvas> <div class="hidden"> <Primary /> </div> <ArgsTable story={PRIMARY_STORY} />
4,531
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/DateInput.stories.tsx
import { useMemo, useState } from 'react'; import { DateInput } from '@proton/components'; import { addDays } from '@proton/shared/lib/date-fns-utc'; import { getTitle } from '../../helpers/title'; import mdx from './DateInput.mdx'; export default { component: DateInput, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; export const Basic = () => { const currentDate = new Date(); const [value, setValue] = useState<Date | undefined>(currentDate); const handleChange = (change: Date | undefined) => { setValue(change); }; const sharedDateInputProps = { value, onChange: handleChange, }; return ( <div> <DateInput {...sharedDateInputProps} /> </div> ); }; export const WithMinAndMax = () => { const currentDate = new Date(); const [value, setValue] = useState<Date | undefined>(currentDate); const min = addDays(currentDate, -3); const max = addDays(currentDate, 3); const handleChange = (change: Date | undefined) => { setValue(change); }; const sharedDateInputProps = { value, onChange: handleChange, }; return ( <div> <DateInput {...sharedDateInputProps} min={min} max={max} /> </div> ); }; export const WithMinAndMaxAndPreventreset = () => { const currentDate = new Date(); const [value, setValue] = useState<Date | undefined>(currentDate); const min = addDays(currentDate, -3); const max = addDays(currentDate, 3); const handleChange = (change: Date | undefined) => { setValue(change); }; const error = useMemo(() => { if (value && value < min) { return 'Choose a date in the future'; } if (value && value > max) { return 'Choose a date in the past'; } return undefined; }, [value]); const sharedDateInputProps = { value, onChange: handleChange, error, }; return ( <div> <DateInput {...sharedDateInputProps} min={min} max={max} preventValueReset /> </div> ); };
4,532
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Details.mdx
import { ArgsTable, Canvas, PRIMARY_STORY, Primary, Story } from '@storybook/addon-docs'; import { Alert, Details } from '@proton/components'; # Details/Summary <Alert> Should not be used anymore, use <a href="?path=/docs/components-collapsible--basic">Collapsible</a> instead </Alert> <Canvas> <Story id="components-details--basic" /> </Canvas> <Canvas> <Story id="components-details--opened" /> </Canvas> <div class="hidden"> <Primary /> </div> <ArgsTable story={PRIMARY_STORY} />
4,533
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Details.stories.tsx
import { Details, Summary } from '@proton/components'; import { getTitle } from '../../helpers/title'; import mdx from './Details.mdx'; export default { component: Details, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; export const Basic = () => { return ( <> <Details> <Summary>Here a summary</Summary> Lorem Ipsum dolor si amet. </Details> </> ); }; export const Opened = () => { return ( <> <Details open> <Summary>Here a summary opened</Summary> Lorem Ipsum dolor si amet. </Details> </> ); };
4,534
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Dropdown.mdx
import { ArgsTable, Canvas, PRIMARY_STORY, Primary, Story } from '@storybook/addon-docs'; # Dropdown `Dropdown` is a component that can be used to display content on top of other content. It can be used together with: - `DropdownButton` (button with a caret) - `DropdownMenu` - `DropdownMenuButton` - `SimpleDropdown` (wraps Dropdown and DropdownButton) ## How to use <Canvas withSource="open"> <Story id="components-dropdown--basic" /> </Canvas> ## Size The size of the dropdown can be customized through the `size` property. <Canvas> <Story id="components-dropdown--size" /> </Canvas> ## Playground <Primary /> <ArgsTable story={PRIMARY_STORY} />
4,535
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Dropdown.stories.tsx
import { useState } from 'react'; import { Button } from '@proton/atoms/Button'; import { Collapsible, CollapsibleContent, CollapsibleHeader, CollapsibleHeaderIconButton, Dropdown, DropdownButton, DropdownMenu, DropdownMenuButton, DropdownProps, DropdownSizeUnit, Icon, Option, SelectTwo, usePopperAnchor, } from '@proton/components'; import { getTitle } from '../../helpers/title'; import mdx from './Dropdown.mdx'; export default { component: Dropdown, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; export const Basic = () => { const { anchorRef, isOpen, toggle, close } = usePopperAnchor<HTMLButtonElement>(); return ( <> <DropdownButton ref={anchorRef} isOpen={isOpen} onClick={toggle} hasCaret> Click me </DropdownButton> <Dropdown isOpen={isOpen} anchorRef={anchorRef} onClose={close}> <DropdownMenu> {['Foo', 'Bar'].map((i) => { return ( <DropdownMenuButton className="text-left" key={i}> {i} </DropdownMenuButton> ); })} </DropdownMenu> <div className="p-4"> <Button className="w-full" color="norm"> Action </Button> </div> </Dropdown> </> ); }; export const Size = () => { const [size, setSize] = useState<NonNullable<DropdownProps['size']>>({ width: DropdownSizeUnit.Static, height: DropdownSizeUnit.Dynamic, maxHeight: '50em', maxWidth: '20em', }); const { anchorRef, isOpen, toggle, close } = usePopperAnchor<HTMLButtonElement>(); const Editor = ({ sizeKey, options, }: Readonly<{ sizeKey: keyof typeof size; options: { title: string; value: DropdownSizeUnit }[]; }>) => { const value = size?.[sizeKey]; const exists = options.find((option) => option.value === (value as any)); return ( <SelectTwo value={exists ? value : 'custom'} onChange={(change) => { setSize((size) => ({ ...size, [sizeKey]: change.value === 'custom' ? '10em' : change.value, })); }} > {[...options, { title: `custom${!exists ? ` (${value})` : ''}`, value: 'custom' }].map((option) => { return <Option key={option.value} title={option.title} value={option.value} />; })} </SelectTwo> ); }; const getOption = (unit: DropdownSizeUnit) => { return { title: `${unit}`, value: unit }; }; return ( <> <div> {[ { sizeKey: 'width' as const, options: [DropdownSizeUnit.Static, DropdownSizeUnit.Dynamic, DropdownSizeUnit.Anchor], }, { sizeKey: 'height' as const, options: [DropdownSizeUnit.Static, DropdownSizeUnit.Dynamic], }, { sizeKey: 'maxWidth' as const, options: [DropdownSizeUnit.Viewport], }, { sizeKey: 'maxHeight' as const, options: [DropdownSizeUnit.Viewport], }, ].map((row) => { return ( <div className="flex flex-align-items-center"> <pre className="w-custom" style={{ '--w-custom': '20em' }}> {row.sizeKey}: </pre> <div className="flex-item-fluid-auto"> <Editor sizeKey={row.sizeKey} options={row.options.map(getOption)} /> </div> </div> ); })} </div> <DropdownButton ref={anchorRef} isOpen={isOpen} onClick={toggle} hasCaret> Click me to open </DropdownButton> <Dropdown isOpen={isOpen} anchorRef={anchorRef} onClose={close} size={size} autoClose={false} autoCloseOutside={false} > <Collapsible className="p-4"> <CollapsibleHeader suffix={ <CollapsibleHeaderIconButton> <Icon name="chevron-down" /> </CollapsibleHeaderIconButton> } > Collapsible header </CollapsibleHeader> <CollapsibleContent> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </CollapsibleContent> </Collapsible> </Dropdown> </> ); };
4,536
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Dropzone.mdx
import { ArgsTable, Canvas, PRIMARY_STORY, Primary, Story } from '@storybook/addon-docs'; import { Dropzone } from '@proton/components'; # Dropzone The Dropzone component provides an area to drag and drop files onto, most likely for uploading. Extra props are spread on the container element, not the overlay. Small notes on the vocabulary we use: - **Children** is what you see when you are not dragging files. - **Content** is what you see in your dropzone when you are dragging files. By default, there is a content set for sizes `small`/`medium`/`large`. But you can override it with the prop `customContent`. **Warning for developers:** In the Dropzone component code, we wanted to avoid creating a container div which would contain the dropzone children and content. This could have caused issues in certain cases (Mostly CSS display which could have created a conflict, meaning that the developer would have needed to create CSS specificities). Instead, we are cloning the children component, and we add it some new props and the dropzone content as a new children. It means that if you want the dropzone to work properly, you might have to spread the rest operator in the children container div of your react component + render the children we're passing. A good example of this usage is in InteractiveCalendarView, which is rendering the TimeGrid. In TimeGrid, we spread the rest prop and render a new children ## Playground <Canvas> <Story id="components-dropzone--custom" /> </Canvas> ## Invisible Dropzone If you want to get a Dropzone that shows no content when hovering but keeps showing the children instead, use the shape `invisible`. <Canvas> <Story id="components-dropzone--invisible" /> </Canvas> <ArgsTable story={PRIMARY_STORY} />
4,537
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Dropzone.stories.tsx
import { SetStateAction, useState } from 'react'; import { Checkbox, Dropzone, InputFieldTwo, RadioGroup } from '@proton/components'; import { DropzoneShape, DropzoneSize } from '@proton/components/components/dropzone/Dropzone'; import { getTitle } from '../../helpers/title'; import mdx from './Dropzone.mdx'; export default { component: Dropzone, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; const sizes: DropzoneSize[] = ['small', 'medium', 'large']; const shapes: DropzoneShape[] = ['norm', 'transparent', 'flashy', 'invisible']; const toggles = ['showDragOverState', 'border', 'rounded', 'disabled'] as const; // Hook only used in the demo const useAddFiles = () => { const [uploadedFiles, setUploadedFiles] = useState<string[]>([]); const handleAddFile = (files: File[]) => { const filenames = files.map((file) => file.name); setUploadedFiles([...uploadedFiles, ...filenames]); }; return { uploadedFiles, setUploadedFiles, handleAddFile }; }; export const Custom = () => { const [content, setContent] = useState(''); const [contentTitle, setContentTitle] = useState(''); const [contentSubtext, setContentSubtext] = useState(''); const [isCustomContent, setIsCustomContent] = useState(false); const [selectedSize, setSelectedSize] = useState<DropzoneSize>('medium'); const [selectedShape, setSelectedShape] = useState<DropzoneShape>('norm'); const [selectedToggles, setSelectedToggles] = useState([false, true, true, false]); const { uploadedFiles, handleAddFile } = useAddFiles(); return ( <div className="p-7"> <div className="flex flex-align-items-stretch"> <div className="mr-7"> <strong className="block mb-4">Size</strong> <RadioGroup name="selected-size" onChange={(v) => setSelectedSize(v)} value={selectedSize} options={sizes.map((size) => ({ value: size, label: size }))} /> </div> <div className="mr-7"> <strong className="block mb-4">Shape</strong> <RadioGroup name="selected-shape" onChange={(v) => setSelectedShape(v)} value={selectedShape} options={shapes.map((shape) => ({ value: shape, label: shape }))} /> </div> <div className="mr-7"> <strong className="block mb-4">Toggles</strong> {toggles.map((prop, i) => { return ( <div className="mb-2"> <Checkbox checked={selectedToggles[i]} onChange={({ target: { checked } }) => { setSelectedToggles( selectedToggles.map((oldValue, otherIndex) => otherIndex === i ? checked : oldValue ) ); }} > {prop} </Checkbox> </div> ); })} </div> <div className="mr-7"> <strong className="block mb-4">Content</strong> <Checkbox checked={isCustomContent} onChange={({ target: { checked } }) => { setIsCustomContent(checked); if (!checked) { setContent(''); } }} className="mb-2" > Custom content </Checkbox> {isCustomContent ? ( <InputFieldTwo name="content" id="content" label="Content" value={content} onChange={(e: { target: { value: SetStateAction<string> } }) => setContent(e.target.value)} placeholder="Set a custom content" /> ) : ( <> {selectedSize === 'large' && ( <InputFieldTwo name="content-title" id="content-title" label="Content title" value={contentTitle} onChange={(e: { target: { value: SetStateAction<string> } }) => setContentTitle(e.target.value) } placeholder="Set a custom content title" /> )} <InputFieldTwo name="content-subtext" id="content-subtext" label="Content subtext" value={contentSubtext} onChange={(e: { target: { value: SetStateAction<string> } }) => setContentSubtext(e.target.value) } placeholder="Set a custom content" /> </> )} </div> </div> <div className="mt-4 flex flex-align-items-center"> <Dropzone onDrop={handleAddFile} size={selectedSize} shape={selectedShape} customContent={content} contentTitle={contentTitle} contentSubText={contentSubtext} {...selectedToggles.reduce<{ [key: string]: boolean }>((acc, value, i) => { acc[toggles[i]] = value; return acc; }, {})} > <div className="flex flex-align-items-center w-full border p-4" style={{ minHeight: '300px' }}> <div className="flex flex-column text-center h-full w-full"> <span>Hover with a file to see the dropzone (or select showDragOverState toggle)</span> <br /> <span>This is the children content</span> <span>You uploaded these files [{uploadedFiles.join(',')}]</span> </div> </div> </Dropzone> </div> </div> ); }; export const Invisible = () => { const { uploadedFiles, handleAddFile } = useAddFiles(); return ( <div className="p-7"> <div className="mt-4 flex flex-align-items-center"> <Dropzone onDrop={handleAddFile} shape="invisible"> <div className="flex flex-align-items-center w-full border p-4" style={{ minHeight: '300px' }}> <div className="flex flex-column text-center h-full w-full"> <span>Hover with a file to see the dropzone (or select showDragOverState toggle)</span> <br /> <span>This is the children content</span> <span>You uploaded these files [{uploadedFiles.join(',')}]</span> </div> </div> </Dropzone> </div> </div> ); };
4,538
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/EllipsisLoader.mdx
import { ArgsTable, Canvas, PRIMARY_STORY, Primary, Story } from '@storybook/addon-docs'; # EllipsisLoader This component is used to indicate that a component is loading (for example on the app loading screen) <Canvas withSource="open"> <Story id="components-ellipsisloader--basic" /> </Canvas> <div class="hidden"> <Primary /> </div>
4,539
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/EllipsisLoader.stories.tsx
import { EllipsisLoader } from '@proton/components'; import { getTitle } from '../../helpers/title'; import mdx from './EllipsisLoader.mdx'; export default { component: EllipsisLoader, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; export const Basic = () => <EllipsisLoader />;
4,540
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Errors.stories.tsx
import { CompatibilityCheckView, getCompatibilityList } from '@proton/components'; import { APPS } from '@proton/shared/lib/constants'; import { getTitle } from '../../helpers/title'; export default { title: getTitle(__filename) }; export { GenericError, InternalServerError, AccessDeniedError, NotFoundError, StandardLoadErrorPage, } from '@proton/components'; export const CompatibilityCheck = () => { return <CompatibilityCheckView appName={APPS.PROTONMAIL} incompatibilities={getCompatibilityList()} />; };
4,541
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Icon.mdx
import { ArgsTable, Canvas, PRIMARY_STORY, Primary, Story } from '@storybook/addon-docs'; import { Icon } from '@proton/components'; # Icon Icon component can have different sizes, configurable via the `size` prop, 16 pixels like by default. They are colored via text color helpers and inherit the parent container's text color by default. All the available icons in our icon set are reachable in the [icon dedicated documentation page](/docs/core-concepts-icons--icons). ### How to use <Canvas withSource="open"> <Story id="components-icon--basic" /> </Canvas> <Canvas> <Story id="components-icon--color" /> </Canvas> ### Playground <Primary /> <ArgsTable story={PRIMARY_STORY} />
4,542
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Icon.stories.tsx
import { Icon, IconProps } from '@proton/components'; import { getTitle } from '../../helpers/title'; import mdx from './Icon.mdx'; export default { component: Icon, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; export const Basic = ({ ...args }: IconProps) => <Icon {...args} />; Basic.args = { name: 'brand-proton-mail', }; export const Color = () => { const colors = ['primary', 'danger', 'success', 'warning', 'info']; const sizes = [12, 16, 24, 40, 48] as const; return ( <div> <div className="flex flex-align-items-end flex-justify-center"> {sizes.map((size) => ( <Icon name="brand-proton-mail" size={size} className="mr-4" /> ))} </div> {colors.map((color) => ( <div className="flex flex-align-items-end flex-justify-center"> {sizes.map((size) => ( <Icon name="brand-proton-mail" size={size} className={`color-${color} mr-4`} /> ))} </div> ))} </div> ); };
4,543
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/InlineLinkButton.mdx
import { Canvas, Primary, Story } from '@storybook/addon-docs'; import { Alert } from '@proton/components'; # InlineLinkButton The InlineLinkButton component is a button with the exact look and behaviour of a link. <Alert type="info"> <b>The InlineLinkButton should only be used inside a text content.</b> If you need a standalone underline button, or placed next to an input field or another button, please refer to the{' '} <a href="?path=/docs/components-button--basic">button with underline shape</a>. </Alert> ## How to use <Canvas withSource="open"> <Story id="components-inlinelinkbutton--basic" /> </Canvas> ## Example <Canvas> <Story id="components-inlinelinkbutton--example" /> </Canvas> <div class="hidden"> <Primary /> </div>
4,544
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/InlineLinkButton.stories.tsx
import { InlineLinkButton } from '@proton/components'; import { getTitle } from '../../helpers/title'; import mdx from './InlineLinkButton.mdx'; export default { component: InlineLinkButton, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; export const Basic = () => ( <InlineLinkButton onClick={() => alert('See? This is a real button.')}>text content</InlineLinkButton> ); export const Example = () => ( <p> Mr. Levet this day shewed me Dr. Johnsonʼs library, which was contained in two garrets{' '} <InlineLinkButton onClick={() => alert('See? This is a real button.')}>over his Chambers</InlineLinkButton>, where Lintot, son of the celebrated bookseller of that name, had formerly his warehouse. I found a number of good books, but very dusty and in great confusion. The floor was strewed with manuscript leaves, in Johnsonʼs own handwriting, which I beheld with a degree of veneration, supposing they perhaps might contain portions of The Rambler or of Rasselas. I observed an apparatus for{' '} <InlineLinkButton onClick={() => alert('See? This is a real button.')}>chymical experiments</InlineLinkButton>, of which Johnson was all his life very fond. The place seemed to be very favourable for{' '} <InlineLinkButton onClick={() => alert('See? This is a real button.')}> retirement and meditation </InlineLinkButton> . Johnson told me, that he went up thither without mentioning it to his servant, when he wanted to study, secure from interruption; for he would not allow his servant to say he was not at home when he really was. "A servantʼs strict regard for truth, — said he — must be weakened by such a practice. that it is merely a form of denial{' '} <InlineLinkButton onClick={() => alert('See? This is a real button.')}>A philosopher may know</InlineLinkButton> ; but few servants are such nice distinguishers. If I accustom a servant to tell a lie for ME, have I not reason to apprehend that he will tell many lies for HIMSELF." </p> );
4,545
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/InputButton.mdx
import { ArgsTable, Canvas, Primary, Story } from '@storybook/addon-docs'; import { InputButton } from '@proton/components'; # InputButton `InputButton` is used to obtain either checkbox or radio functionality, however with the input element being represented as a circular button. ### Basic <Canvas withSource="open"> <Story id="components-inputbutton--basic" /> </Canvas> ### Multiple Checkbox style usage of this component. Under the hood this is the same as `<input type="checkbox" />`. <Canvas> <Story id="components-inputbutton--multiple" /> </Canvas> ### Exclusive You can of course also render an array of this component and make only a single value selectable using the `checked` prop and handling that logic yourself. When you need to use this component like just described, please make sure to make it a `type="radio"`. That makes for better for accessibility (semantics & keyboard navigation). Be aware that this also changes the interface usage of this component in the same way it would for a native `<input type="radio" />`. <Canvas> <Story id="components-inputbutton--exclusivity" /> </Canvas> <div class="hidden"> <Primary /> </div> <ArgsTable of={InputButton} />
4,546
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/InputButton.stories.tsx
import { useState } from 'react'; import { InputButton } from '@proton/components'; import remove from '@proton/utils/remove'; import { getTitle } from '../../helpers/title'; import mdx from './InputButton.mdx'; export default { component: InputButton, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; export const Basic = () => { const [checked, setChecked] = useState(false); const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => { setChecked(e.target.checked); }; return ( <InputButton id="checkbox" title="checkbox" checked={checked} onChange={handleChange}> A </InputButton> ); }; export const Multiple = () => { const [checkedIds, setCheckedIds] = useState<string[]>([]); const handleChange = (id: string) => (e: React.ChangeEvent<HTMLInputElement>) => { if (e.target.checked) { setCheckedIds([...checkedIds, id]); } else { setCheckedIds(remove(checkedIds, id)); } }; return ( <div> {['1', '2', '3', '4', '5'].map((n) => ( <InputButton id={n} title="checkbox" checked={checkedIds.includes(n)} onChange={handleChange(n)} labelProps={{ className: 'mr-4' }} > {n} </InputButton> ))} </div> ); }; export const Exclusivity = () => { const [checkedId, setCheckedId] = useState<null | string>(null); const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => { setCheckedId(e.target.value); }; return ( <div> {['1', '2', '3', '4', '5'].map((n) => ( <InputButton id={`radio-${n}`} title="radio" type="radio" value={n} checked={n === checkedId} onChange={handleChange} labelProps={{ className: 'mr-4' }} > {n} </InputButton> ))} </div> ); };
4,547
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/InputField.mdx
import { ArgsTable, Canvas, PRIMARY_STORY, Primary, Story } from '@storybook/addon-docs'; # InputField An `InputField` is a wrapper taking [any input component](#custom-elements) and adding decoration around it. ## How to use <Canvas withSource="open"> <Story id="components-inputfield--basic" /> </Canvas> ## Playground <Story id="components-inputfield--sandbox" /> ## Options The `placeholder`, `hint`, `assistiveText`, and `disabled` props provide additional configuration. <Canvas> <Story id="components-inputfield--intermediate" /> </Canvas> ## Validation The `error` and `warning` props toggle the error state. If a node is provided, the `assistiveText` will be replaced. <Canvas> <Story id="components-inputfield--validation" /> </Canvas> ## Adornments <Canvas> <Story id="components-inputfield--adornments" /> </Canvas> ## Sizes The `bigger` prop to increases the size. <Canvas> <Story id="components-inputfield--sizes" /> </Canvas> ## Dense inputs The `dense` prop removes assistive text and shows errors and warnings as a tooltip. Can be used when space is scarce. <Canvas> <Story id="components-inputfield--dense" /> </Canvas> ## Custom elements The `as` prop allows for `InputField` to render as another element such as a `PasswordInput`, `PhoneInput`, `TextArea`, `Select`, `Toggle`, or `ColorPicker`. Defaults to `Input`. <Canvas> <Story id="components-inputfield--custom-elements" /> </Canvas> ## Playground <Primary /> <ArgsTable story={PRIMARY_STORY} />
4,548
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/InputField.stories.tsx
import { useState } from 'react'; import { Button } from '@proton/atoms'; import { Checkbox, ColorPicker, Icon, InputFieldTwo, Option, PasswordInputTwo, PhoneInput, RadioGroup, SelectTwo, TextAreaTwo, Toggle, TotpInput, } from '@proton/components'; import { getTitle } from '../../helpers/title'; import mdx from './InputField.mdx'; export default { component: InputFieldTwo, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; export const Basic = () => ( <InputFieldTwo label="What this input field is about" hint="Any hint on filling this input field" assistiveText="Assistive text explaining how to fill this input field…" placeholder="Ex: example of a correct filling…" title="Help displayed on hovering this input field, and read by screen readers too." prefix={<Icon name="robot" />} /> ); const toggles = ['dense', 'bigger', 'unstyled', 'disabled'] as const; const adornmentIds = ['none', 'text', 'select', 'icon', 'icons', 'icon button'] as const; export const Sandbox = () => { const [label, setLabel] = useState<string>('Label'); const [hint, setHint] = useState<string>('Hint'); const [placeholder, setPlaceholder] = useState<string>('Placeholder'); const [assistiveText, setAssistiveText] = useState<string>(''); const [error, setError] = useState<string>(''); const [warning, setWarning] = useState<string>(''); const [selectedSuffixId, setSelectedSuffixId] = useState<string>('none'); const [selectedPrefixId, setSelectedPrefixId] = useState<string>('none'); const [selectedToggles, setSelectedToggles] = useState(toggles.map(() => false)); const getAdornment = (id: string) => { if (id === 'text') { return 'text adornment'; } if (id === 'icon') { return <Icon name="brand-proton" />; } if (id === 'icons') { return ( <> <Icon name="brand-proton-mail" /> <Icon name="brand-proton-calendar" /> </> ); } if (id === 'icon button') { return ( <Button onClick={() => { alert('Clicked!'); }} shape="ghost" size="small" icon className="rounded-sm" disabled={selectedToggles[toggles.indexOf('disabled')]} > <Icon name="brand-proton" /> </Button> ); } if (id === 'select') { return ( <SelectTwo unstyled value="Item 1" disabled={selectedToggles[toggles.indexOf('disabled')]}> <Option key="1" value="Item 1" title="Item 1"> Item 1 </Option> <Option key="2" value="Item 2" title="Item 2"> Item 2 </Option> </SelectTwo> ); } }; return ( <> <div className="flex flex-item-fluid flex-align-items-center flex-justify-center border p-7"> <InputFieldTwo label={label} hint={hint} assistiveText={assistiveText} placeholder={placeholder} error={error} warning={warning} prefix={getAdornment(selectedPrefixId)} suffix={getAdornment(selectedSuffixId)} {...selectedToggles.reduce<{ [key: string]: boolean }>((acc, value, i) => { acc[toggles[i]] = value; return acc; }, {})} /> </div> <div className="flex flex-nowrap gap-7 py-7"> <div className="w-1/4"> <InputFieldTwo label="Label" value={label} onValue={setLabel} /> <InputFieldTwo label="Hint" value={hint} onValue={setHint} /> <InputFieldTwo label="Placeholder" value={placeholder} onValue={setPlaceholder} /> </div> <div className="w-1/4"> <InputFieldTwo label="AssistiveText" value={assistiveText} onValue={setAssistiveText} /> <InputFieldTwo label="Error" value={error} onValue={setError} /> <InputFieldTwo label="Warning" value={warning} onValue={setWarning} /> </div> <div> <strong className="block mb-4">Prefix</strong> <RadioGroup name="selected-prefix" value={selectedPrefixId} onChange={setSelectedPrefixId} options={adornmentIds.map((suffix) => ({ value: suffix, label: suffix }))} /> </div> <div> <strong className="block mb-4">Suffix</strong> <RadioGroup name="selected-suffix" value={selectedSuffixId} onChange={setSelectedSuffixId} options={adornmentIds.map((suffix) => ({ value: suffix, label: suffix }))} /> </div> <div> <strong className="block mb-4">Toggles</strong> {toggles.map((prop, i) => { return ( <div className="mb-2"> <Checkbox checked={selectedToggles[i]} onChange={({ target: { checked } }) => { setSelectedToggles( selectedToggles.map((oldValue, otherIndex) => otherIndex === i ? checked : oldValue ) ); }} > {prop} </Checkbox> </div> ); })} </div> </div> </> ); }; export const Intermediate = () => { const [value, setValue] = useState(''); const placeholder = "e.g. 'John Fitzgerald'"; return ( <> <InputFieldTwo label="Placeholder" placeholder={placeholder} /> <InputFieldTwo label="Hint" hint={`${value.length}/100`} value={value} onValue={setValue} /> <div className="mb-4"> <InputFieldTwo label="Assistive Text" assistiveText="Your legal surname/s (separated by spaces)" /> </div> <InputFieldTwo disabled label="Disabled" placeholder={placeholder} assistiveText="Your legal surname/s (separated by spaces)" /> </> ); }; export const Validation = () => { const sharedInputProps = { placeholder: "e.g. 'John Fitzgerald'", }; return ( <> <div className="mb-4"> <InputFieldTwo label="Warning as string" warning="Something's not quite right here" {...sharedInputProps} /> </div> <div className="mb-4"> <InputFieldTwo label="Error as string" error="Something's definitely not right here" {...sharedInputProps} /> </div> <div className="mb-4"> <InputFieldTwo label="Warning as boolean" warning assistiveText="Should be hidden" {...sharedInputProps} /> </div> <div> <InputFieldTwo label="Error as boolean" error assistiveText="Should be hidden" {...sharedInputProps} /> </div> </> ); }; export const Adornments = () => { return ( <> <InputFieldTwo label="Input with icon prefix" prefix={<Icon name="magnifier" />} /> <InputFieldTwo label="Input with text prefix" prefix="Prefix" /> <InputFieldTwo label="Input with icon suffix" placeholder="**** **** **** ****" suffix={<Icon name="credit-card" />} /> <InputFieldTwo label="Input with text suffix" placeholder="username" suffix="@protonmail.com" /> <InputFieldTwo label="Input with select suffix" placeholder="username" suffix={ <SelectTwo unstyled value="pm.me"> <Option key="pm.me" value="pm.me" title="pm.me"> @pm.me </Option> <Option key="protonmail.com" value="protonmail.com" title="protonmail.com"> @protonmail.com </Option> </SelectTwo> } /> </> ); }; export const Sizes = () => { const sharedInputProps = { placeholder: "e.g. 'John Fitzgerald'", }; return ( <> <InputFieldTwo label="Default" {...sharedInputProps} /> <InputFieldTwo label="Bigger" bigger {...sharedInputProps} /> </> ); }; export const Dense = () => { return ( <> <InputFieldTwo dense label="Warning" warning="I'm a warning" /> <InputFieldTwo dense label="Error" error="I'm an error" /> <InputFieldTwo dense label="Assistive text" assistiveText="I'm invisible" /> <InputFieldTwo dense label="Error with suffix" error="I'm an error" as={PasswordInputTwo} /> </> ); }; export const CustomElements = () => { const [phone, setPhone] = useState(''); const [color, setColor] = useState(''); const [toggleChecked, setToggleChecked] = useState(false); const [checked, setChecked] = useState(false); const [totp, setTotp] = useState(''); return ( <> <InputFieldTwo as={PasswordInputTwo} label="Password input" placeholder="Password" /> <InputFieldTwo as={PhoneInput} label="Phone input" placeholder="Phone number" value={phone} onChange={setPhone} /> <InputFieldTwo as={TextAreaTwo} rows={3} label="Text area" placeholder="Placeholder" /> <InputFieldTwo as={SelectTwo} label="Select" placeholder="one"> <Option title="one" value="one" /> <Option title="two" value="two" /> <Option title="three" value="three" /> </InputFieldTwo> <InputFieldTwo as={Toggle} label="Toggle" checked={toggleChecked} onChange={() => setToggleChecked(!toggleChecked)} /> <InputFieldTwo as={Checkbox} label="Checkbox" checked={checked} onChange={() => setChecked(!checked)} /> <InputFieldTwo as={ColorPicker} label="Color picker" color={color} onChange={setColor} /> <div style={{ maxWidth: 250 }}> <InputFieldTwo as={TotpInput} label="TOTP input" length={6} value={totp} onValue={setTotp} /> </div> </> ); };
4,549
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/LabelStack.mdx
import { ArgsTable, Canvas, Primary, Story } from '@storybook/addon-docs'; import { Label, LabelStack } from '@proton/components'; # LabelStack The `LabelStack` component allows you to add a label list with embeded look and feel, with interactions, buttons for filtering or removing. Please use the this component even if you have one and only label to display. `max-w-full`: on main container, will remove the maximum width set to 10em on each item. ## Basic <Canvas withSource="open"> <Story id="components-labelstack--basic" /> </Canvas> ## Clickable <Canvas> <Story id="components-labelstack--clickable" /> </Canvas> ## With delete option <Canvas> <Story id="components-labelstack--with-delete" /> </Canvas> ## With stacked option <Canvas> <Story id="components-labelstack--stacked" /> </Canvas> ## With max number option <Canvas> <Story id="components-labelstack--max" /> </Canvas> ## With show dropdown option <Canvas> <Story id="components-labelstack--dropdown" /> </Canvas> <div class="hidden"> <Primary /> </div> <ArgsTable of={LabelStack} />
4,550
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/LabelStack.stories.tsx
import { LabelStack } from '@proton/components'; import { getTitle } from '../../helpers/title'; import mdx from './LabelStack.mdx'; export default { component: LabelStack, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; const labelList = [ { color: '#8080FF', title: 'electron' }, { color: '#EC3E7C', title: 'muon' }, { color: '#DB60D6', title: 'tau' }, { color: '#415DF0', title: 'neutrino' }, { color: '#179FD9', title: 'z boson' }, { color: '#1DA583', title: 'w boson' }, { color: '#3CBB3A', title: 'quark' }, { color: '#B4A40E', title: 'higgs' }, { color: '#936D58', title: 'photon' }, { color: '#F78400', title: 'gluon' }, ].map(({ color, title }) => ({ title, name: title, color: color, })); const labelListWithHandlers = labelList.map((label) => ({ ...label, onClick() { alert(`You clicked on "${label.name}"`); }, onDelete() { alert(`You deleted "${label.name}"`); }, })); export const Basic = () => <LabelStack labels={labelList} />; export const Clickable = () => <LabelStack labels={labelListWithHandlers} />; export const WithDelete = () => <LabelStack labels={labelListWithHandlers} showDelete />; export const Stacked = () => ( <div className="flex flex-justify-space-between"> <LabelStack labels={labelList} isStacked leftToRight /> <LabelStack labels={labelList} isStacked /> </div> ); export const Max = () => <LabelStack labels={labelList} maxNumber={5} />; export const Dropdown = () => <LabelStack labels={labelListWithHandlers} showDropDown />;
4,551
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Logo.mdx
import { ArgsTable, Canvas, PRIMARY_STORY, Primary, Story } from '@storybook/addon-docs'; import { Alert, Logo } from '@proton/components'; import { APPS } from '@proton/shared/lib/constants'; # Logo A group of components to render all kinds of proton app & brand logos that we support. <Canvas withSource="open"> <Story id="components-logo--basic" /> </Canvas> ## Variants The `<Logo />` component allow you to render all logos in all possible variants. <Story id="components-logo--sandbox" /> ## Individual You can also individually import and use any particular logo directly. <Alert type="info"> One logo that isn't available through the <code>&lt;Logo /&gt;</code> component is the{' '} <code>&lt;ProtonLogo /&gt;</code> component. </Alert> <Canvas> <Story id="components-logo--individual" /> </Canvas> ## Playground <Primary /> <ArgsTable story={PRIMARY_STORY} />
4,552
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Logo.stories.tsx
import { useState } from 'react'; import { CalendarLogo, DriveLogo, Logo, LogoProps, MailLogo, PassLogo, ProtonLogo, RadioGroup, VpnLogo, } from '@proton/components'; import { APPS } from '@proton/shared/lib/constants'; import { getTitle } from '../../helpers/title'; import mdx from './Logo.mdx'; export default { component: Logo, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; export const Basic = ({ ...args }: LogoProps) => <Logo {...args} />; Basic.args = { appName: APPS.PROTONMAIL, variant: 'with-wordmark', } as LogoProps; const appNames: Required<LogoProps>['appName'][] = [ APPS.PROTONMAIL, APPS.PROTONCALENDAR, APPS.PROTONDRIVE, APPS.PROTONVPN_SETTINGS, APPS.PROTONPASS, ]; const variants: Required<LogoProps>['variant'][] = ['with-wordmark', 'glyph-only']; export const Sandbox = () => { const [selectedAppName, setSelectedAppName] = useState<Required<LogoProps>['appName']>(APPS.PROTONMAIL); const [selectedVariant, setSelectedVariant] = useState<Required<LogoProps>['variant']>('with-wordmark'); const logo = <Logo appName={selectedAppName} variant={selectedVariant} />; return ( <div className="my-8"> <div className="flex flex-align-items-stretch"> <div className="mr-8"> <strong className="block mb-4">App Name</strong> <RadioGroup name="selected-app-name" onChange={setSelectedAppName} value={selectedAppName} options={appNames.map((appName) => ({ value: appName, label: appName }))} /> </div> <div className="mr-8"> <strong className="block mb-4">Variant</strong> <RadioGroup name="selected-variant" onChange={setSelectedVariant} value={selectedVariant} options={variants.map((variant) => ({ value: variant, label: variant }))} /> </div> <div className="flex flex-item-fluid flex-align-items-center flex-justify-center border">{logo}</div> </div> </div> ); }; export const Individual = () => ( <div> <div className="mb-8"> <ProtonLogo variant="glyph-only" /> </div> <div className="mb-8"> <ProtonLogo /> </div> <div className="mb-8"> <MailLogo /> </div> <div className="mb-8"> <CalendarLogo /> </div> <div className="mb-8"> <DriveLogo /> </div> <div className="mb-8"> <VpnLogo /> </div> <div> <PassLogo /> </div> </div> );
4,553
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Meter.mdx
import { ArgsTable, Canvas, PRIMARY_STORY, Primary, Story } from '@storybook/addon-docs'; import { Meter } from '@proton/components'; # Meter The `Meter` component must only be used for a visual rendering of a graduated and limited value, not for a progression. For a progression value, see [Progress](?path=/docs/components-progress--basic#progress) component. - `min` is the minimum value of your data, lower than `max` - `max` is the maximum value of your data, higher than `min` - `low` is a value of your data that can be understood as low, within the range of min and `max` - `high` is a value of your data that can be understood as high, within the range of min and `max` - `optimum` is the optimal value of your data, within the range of `min` and `max`. This will influent the behaviour of `low` and `high`: it gives an indication where along the range is considered preferable. For example, if it is between the `min` attribute and the `low` attribute, then the lower range is considered preferred. Further explanations: - If the `optimum` value is lower than `low` value, it indicates that the lower values are optimum, so lower values will be green, between `low` and `high` will be yellow, and red higher than `high` - If the `optimum` value is higher than `high` value, it indicates that the higher values are optimum, so lower values will be red, between `low` and `high` will be yellow, and green higher than `high` - If the `optimum` value is between `low` and `high` values, it indicates that extremes values aren't the best, so they will be yellow, and values between `low` and `high` will be green For simplicity, we have set default parameters of the `<Meter>` react component as if you would use a percentage, so they are `min="0"` `max="100"` `low="50"` `high="80"` `optimum="0"`. With those default values, since `optimum` value is lower than low value, you will have: - Green between `0` and `49` - Yellow between `50` and `79` - Red from `80`, including higher than `100` <Canvas> <Story id="components-meter--basic" /> </Canvas> ### Variants The meter comes in two different sizes: default and thin. <Canvas> <Story id="components-meter--variants" /> </Canvas> <Primary /> <ArgsTable story={PRIMARY_STORY} />
4,554
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Meter.stories.tsx
import { Meter } from '@proton/components'; import { getTitle } from '../../helpers/title'; import mdx from './Meter.mdx'; export default { component: Meter, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; export const Primary = ({ ...args }) => <Meter {...args} />; Primary.args = { min: 0, low: 50, high: 80, max: 100, optimum: 0, value: 50, }; export const Basic = () => { return ( <> <Meter className="my-4" value={20} /> <Meter className="my-4" value={75} /> <Meter className="my-4" value={100} /> </> ); }; export const Variants = () => { return ( <> <Meter className="my-4" value={40} /> <Meter className="my-4" thin value={40} /> </> ); };
4,555
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/MiddleEllipsis.mdx
import { ArgsTable, Canvas, Primary, Story } from '@storybook/addon-docs'; import { MiddleEllipsis } from '@proton/components'; # MiddleEllipsis When you don't have enough space to display something, but you want to display the end of this content. For sure, if you have enough room, ellipsis won't appear. :) ### Basic <Canvas withSource="open"> <Story id="components-middleellipsis--basic" /> </Canvas> ### Without title If this component is wrapped into a button with already a tooltip or a title, you might want not having the title, thanks to `displayTitle={false}` <Canvas> <Story id="components-middleellipsis--title" /> </Canvas> If needed, this component can have some additional classes. <Canvas withSource="open"> <Story id="components-middleellipsis--classes" /> </Canvas> <div class="hidden"> <Primary /> </div> <ArgsTable of={MiddleEllipsis} />
4,556
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/MiddleEllipsis.stories.tsx
import { MiddleEllipsis } from '@proton/components'; import { getTitle } from '../../helpers/title'; import mdx from './MiddleEllipsis.mdx'; export default { component: MiddleEllipsis, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; const textToEllipsis = `mySuperLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongFile.jpg`; export const Basic = () => <MiddleEllipsis text={textToEllipsis} />; export const Title = () => <MiddleEllipsis displayTitle={false} text={textToEllipsis} />; export const Classes = () => <MiddleEllipsis className="w-1/2" text={textToEllipsis} />;
4,557
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Modal.mdx
import { ArgsTable, Canvas, PRIMARY_STORY, Primary, Story } from '@storybook/addon-docs'; import { Alert } from '@proton/components'; # Modal Modals are made of multiple composite components, namely: - `ModalTwo` - `ModalTwoHeader` - `ModalTwoContent` - `ModalTwoFooter` <Alert> Please note that the old <code>Modal</code> component is deprecated and should be replaced with{' '} <code>ModalTwo</code>. This document is about the new <code>ModalTwo</code> component. </Alert> ## How to use ```javascript import { ModalTwo, ModalTwoContent, ModalTwoFooter, ModalTwoHeader } from '@proton/components'; ``` <Canvas withSource="open"> <Story id="components-modal--example" /> </Canvas> ## Variants ### Size Modals come in four different sizes. `small`, `medium`, `large` & `full`. <Canvas> <Story id="components-modal--primary" /> </Canvas> ### Using `useModalState` For use-cases where one would prefer to lose the local state (e.g. form state) of a given modal after it closes/exits, you can use the `useModalState` hook. Internally, the react-node is un- & re-mounted by incrementing and passing of a `key` after each `onExit` call. <Canvas> <Story id="components-modal--using-use-modal-state" /> </Canvas> ### Title in Header The `ModalHeader` comes with some built-ins. It will always display a close button, and optionally a back button, a title and a subline. There is another optional built-in called `actions` covered in the next story. <Canvas> <Story id="components-modal--header" /> </Canvas> ### Actions in Header You can add up to two icon button to the header of a modal. <Canvas> <Story id="components-modal--header-actions" /> </Canvas> ### Scrollable content When a Modal's content is so large that it exceeds the Modal's allowed maximum height (depending of course also on its width) it will become scrollable. This is easy to see in this example as there is a lot of content, however this can also be seen if you reduce the viewport height by a lot. <Canvas> <Story id="components-modal--a-lot-of-content" /> </Canvas> ### Full screen on mobile Modals can cover the entire screen on mobile widths by using the `fullscreenOnMobile` prop. <Canvas> <Story id="components-modal--fullscreen-on-mobile" /> </Canvas> ### Using an html form tag as the root element You can exchange the root element used for the `Modal` with an html `form` tag by leveraging the `as` prop. <Canvas> <Story id="components-modal--with-form-root" /> </Canvas> ### Prompt The `Prompt` is a special variant of the `Modal` component. It is not composite, meant not to be too flexible and comes with a comparatively rudimentary props api, allowing only the passing of some templating props. The `actions` prop is indented to for one or mutliple `Checkbox` elements. <Canvas> <Story id="components-modal--prompt-basic" /> </Canvas> <Canvas> <Story id="components-modal--prompt-with-only-one-button" /> </Canvas> <Canvas> <Story id="components-modal--prompt-with-footnote" /> </Canvas> ### BasicModal Similarly to `Prompt`, `BasicModal` is a special variant of the `Modal` component. It is not composite, meant not to be too flexible and comes with a comparatively rudimentary props api, allowing only the passing of some templating props. It also uses `useModalState` internally. <Canvas> <Story id="components-modal--basic" /> </Canvas> The props for `ModalTwoContent` & `ModalTwoFooter` aren't listed here because they don't possess any proprietary props, only the native ones of their respective underlying root dom-node. <div class="hidden"> <Primary /> </div> <ArgsTable story={PRIMARY_STORY} />
4,558
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Modal.stories.tsx
import { useState } from 'react'; import { Button } from '@proton/atoms'; import { BasicModal, Checkbox, Form, Icon, InputFieldTwo, ModalProps, ModalSize, ModalTwo, ModalTwoContent, ModalTwoFooter, ModalTwoHeader, Prompt, RadioGroup, Tooltip, useModalState, } from '@proton/components'; import { getTitle } from '../../helpers/title'; import mdx from './Modal.mdx'; export default { component: ModalTwo, subcomponents: { ModalTwoHeader, Prompt }, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; export const Example = () => { const [open, setOpen] = useState(false); return ( <div className="text-center"> <Button className="mr-2" onClick={() => { setOpen(true); }} > Open modal </Button> <ModalTwo open={open} onClose={() => setOpen(false)}> <ModalTwoHeader title="Example Modal" /> <ModalTwoContent> <p> Lorem ipsum dolor sit amet consectetur adipisicing elit. Praesentium unde, blanditiis rem accusamus obcaecati enim amet, voluptatibus nemo facilis illum aut itaque in? Deleniti iure amet qui vero, blanditiis quos? </p> </ModalTwoContent> <ModalTwoFooter> <Button>Secondary action</Button> <Button color="norm">Primary action</Button> </ModalTwoFooter> </ModalTwo> </div> ); }; export const Primary = () => { const [size, setSize] = useState<ModalSize>('medium'); const [open, setOpen] = useState(false); return ( <div className="text-center"> <Button className="mr-2" onClick={() => { setOpen(true); }} > Open size modal </Button> <ModalTwo size={size} open={open} onClose={() => setOpen(false)}> <ModalTwoHeader title="Size" /> <ModalTwoContent> <p> Lorem ipsum dolor sit amet consectetur adipisicing elit. Praesentium unde, blanditiis rem accusamus obcaecati enim amet, voluptatibus nemo facilis illum aut itaque in? Deleniti iure amet qui vero, blanditiis quos? </p> <div className="mr-8"> <strong className="block mb-4">Shape</strong> <RadioGroup name="selected-shape" onChange={setSize} value={size} options={(['small', 'medium', 'large', 'xlarge', 'full'] as const).map((size) => ({ value: size, label: size, }))} /> </div> </ModalTwoContent> <ModalTwoFooter> <Button>Secondary action</Button> <Button color="norm">Primary action</Button> </ModalTwoFooter> </ModalTwo> </div> ); }; const WrappedFormModal = (props: ModalProps) => { const [name, setName] = useState(''); return ( <ModalTwo {...props}> <ModalTwoHeader title="Title in ModalHeader" subline="Subline in ModalHeader" /> <ModalTwoContent> <p>I will lose any local state of mine after closing.</p> <InputFieldTwo value={name} label="Name" placeholder="e.g. John Fitzgerald..." onValue={setName} /> </ModalTwoContent> <ModalTwoFooter> <Button>Secondary action</Button> <Button color="norm">Primary action</Button> </ModalTwoFooter> </ModalTwo> ); }; export const UsingUseModalState = () => { const [modalProps, setOpen] = useModalState(); return ( <div className="text-center"> <Button onClick={() => { setOpen(true); }} > Open modal with useModalState </Button> <WrappedFormModal {...modalProps} /> </div> ); }; export const Header = () => { const [open, setOpen] = useState(false); return ( <div className="text-center"> <Button onClick={() => { setOpen(true); }} > Open modal with header extras </Button> <ModalTwo open={open} onClose={() => setOpen(false)}> <ModalTwoHeader title="Title in ModalHeader" subline="Subline in ModalHeader" /> <ModalTwoContent> <p className="m-0"> Lorem ipsum dolor sit amet consectetur adipisicing elit. Praesentium unde, blanditiis rem accusamus obcaecati enim amet, voluptatibus nemo facilis illum aut itaque in? Deleniti iure amet qui vero, blanditiis quos? </p> </ModalTwoContent> <ModalTwoFooter> <Button>Secondary action</Button> <Button color="norm">Primary action</Button> </ModalTwoFooter> </ModalTwo> </div> ); }; export const HeaderActions = () => { const [open, setOpen] = useState(false); return ( <div className="text-center"> <Button onClick={() => { setOpen(true); }} > Open actions modal </Button> <ModalTwo open={open} onClose={() => setOpen(false)}> <ModalTwoHeader actions={[ <Tooltip title="Get help"> <Button icon shape="ghost"> <Icon name="question-circle" /> </Button> </Tooltip>, <Tooltip title="Refresh"> <Button icon shape="ghost"> <Icon name="arrows-rotate" /> </Button> </Tooltip>, ]} /> <ModalTwoContent> <p className="m-0"> Lorem ipsum dolor sit amet consectetur adipisicing elit. Praesentium unde, blanditiis rem accusamus obcaecati enim amet, voluptatibus nemo facilis illum aut itaque in? Deleniti iure amet qui vero, blanditiis quos? </p> </ModalTwoContent> <ModalTwoFooter> <Button>Secondary action</Button> <Button color="norm">Primary action</Button> </ModalTwoFooter> </ModalTwo> </div> ); }; export const ALotOfContent = () => { const [open, setOpen] = useState(false); return ( <div className="text-center"> <Button onClick={() => { setOpen(true); }} > Open modal with a lot of content </Button> <ModalTwo open={open} onClose={() => setOpen(false)}> <ModalTwoHeader title="Title in header" /> <ModalTwoContent> <p> Lorem ipsum dolor sit amet consectetur adipisicing elit. Autem, voluptatum deserunt rem amet consectetur perspiciatis placeat error doloribus vero voluptate quisquam numquam expedita, ex maxime quas, nemo labore necessitatibus accusamus. </p> <p> Delectus blanditiis corporis et est exercitationem odio itaque vero! Fugiat sit eius minus! Architecto quibusdam nisi ullam impedit vel repellat amet, molestias, beatae repudiandae quis fugit, qui ea assumenda maxime. </p> <p> Deserunt rerum aspernatur sint placeat natus nisi quas, facere nesciunt quos obcaecati at suscipit hic modi incidunt numquam necessitatibus labore? Maxime nisi repellendus enim cum nostrum. Officiis porro fuga asperiores? </p> <p> Voluptates minus soluta, ullam maxime labore vitae saepe porro mollitia beatae perferendis velit quasi quidem. Similique numquam repellendus nulla adipisci dolore tempore tenetur laudantium. Sed debitis eos odit beatae soluta? </p> <p> Deleniti, dicta velit. Magnam optio rerum esse est nisi neque unde quos, natus quam aperiam dignissimos porro harum, maxime sed laudantium voluptas cum nam officiis molestiae. Quas iure dicta consectetur. </p> <p> Dolorum ducimus iste asperiores quibusdam laudantium soluta, doloremque minus incidunt distinctio quod dolorem. Nulla nam vitae rerum impedit iste, accusantium veritatis aut, hic animi optio blanditiis, repellat fugit dicta maxime! </p> <p> Quaerat sequi, quis doloribus vel asperiores unde nam excepturi facere consequuntur delectus officia dolorem et itaque sunt iste, suscipit maiores fugiat minus cum! Et id nostrum, officiis facilis voluptas fugiat. </p> <p> Ratione praesentium atque, eveniet nulla expedita distinctio assumenda odit suscipit non architecto accusamus quaerat quod fuga omnis veniam error reprehenderit. At aut impedit excepturi tenetur nulla molestias possimus totam vitae. </p> <p> Molestiae, delectus quae itaque illum impedit eligendi. Molestiae cumque, nam repellat modi dolorum quisquam sequi voluptates velit repudiandae numquam vel quis. Excepturi adipisci hic velit veritatis tenetur, aliquid quod maiores? </p> <p> Pariatur, sint nostrum accusamus dolorum eveniet esse totam praesentium nemo ipsum mollitia quod ad nisi beatae. Veniam, rem illum ratione alias dolores eos sit officia necessitatibus tempora, earum adipisci iure! </p> </ModalTwoContent> <ModalTwoFooter> <Button>Secondary action</Button> <Button color="norm">Primary action</Button> </ModalTwoFooter> </ModalTwo> </div> ); }; export const WithFormRoot = () => { const [open, setOpen] = useState(false); const [value, setValue] = useState(''); const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => { e.preventDefault(); window.alert(`Form submitted, value: ${value}.`); }; return ( <div className="text-center"> <Button className="mr-2" onClick={() => { setOpen(true); }} > Open modal with form root </Button> <ModalTwo open={open} onClose={() => setOpen(false)} as={Form} onSubmit={handleSubmit}> <ModalTwoHeader title="Size" /> <ModalTwoContent> <p> Lorem ipsum dolor sit amet consectetur adipisicing elit. Praesentium unde, blanditiis rem accusamus obcaecati enim amet, voluptatibus nemo facilis illum aut itaque in? Deleniti iure amet qui vero, blanditiis quos? </p> <p> Lorem ipsum dolor sit amet consectetur adipisicing elit. Praesentium unde, blanditiis rem accusamus obcaecati enim amet, voluptatibus nemo facilis illum aut itaque in? Deleniti iure amet qui vero, blanditiis quos? </p> <p> Lorem ipsum dolor sit amet consectetur adipisicing elit. Praesentium unde, blanditiis rem accusamus obcaecati enim amet, voluptatibus nemo facilis illum aut itaque in? Deleniti iure amet qui vero, blanditiis quos? </p> <p> Lorem ipsum dolor sit amet consectetur adipisicing elit. Praesentium unde, blanditiis rem accusamus obcaecati enim amet, voluptatibus nemo facilis illum aut itaque in? Deleniti iure amet qui vero, blanditiis quos? </p> <p> Lorem ipsum dolor sit amet consectetur adipisicing elit. Praesentium unde, blanditiis rem accusamus obcaecati enim amet, voluptatibus nemo facilis illum aut itaque in? Deleniti iure amet qui vero, blanditiis quos? </p> <p> Lorem ipsum dolor sit amet consectetur adipisicing elit. Praesentium unde, blanditiis rem accusamus obcaecati enim amet, voluptatibus nemo facilis illum aut itaque in? Deleniti iure amet qui vero, blanditiis quos? </p> <p> Lorem ipsum dolor sit amet consectetur adipisicing elit. Praesentium unde, blanditiis rem accusamus obcaecati enim amet, voluptatibus nemo facilis illum aut itaque in? Deleniti iure amet qui vero, blanditiis quos? </p> <div className="mt-4"> <InputFieldTwo label="Name" value={value} onValue={setValue} placeholder="e.g. John Fitzgerald" /> </div> </ModalTwoContent> <ModalTwoFooter> <Button onClick={() => { setOpen(false); }} > Cancel </Button> <Button type="submit" color="norm"> Submit </Button> </ModalTwoFooter> </ModalTwo> </div> ); }; export const FullscreenOnMobile = () => { const [open, setOpen] = useState(false); return ( <div className="text-center"> <Button className="mr-2" onClick={() => { setOpen(true); }} > Open full screen on mobile modal </Button> <ModalTwo fullscreenOnMobile open={open} onClose={() => setOpen(false)}> <ModalTwoHeader /> <ModalTwoContent> <p> If I&apos;m not full screen you&apos;ll have to make your screen&apos;s width smaller. If you did that and I&apos;m still not fullscreen that means my developers did a shlopey job. </p> <p> Lorem ipsum dolor sit amet consectetur adipisicing elit. Praesentium unde, blanditiis rem accusamus obcaecati enim amet, voluptatibus nemo facilis illum aut itaque in? Deleniti iure amet qui vero, blanditiis quos? </p> </ModalTwoContent> <ModalTwoFooter> <Button>Secondary action</Button> <Button color="norm">Primary action</Button> </ModalTwoFooter> </ModalTwo> </div> ); }; export const PromptBasic = () => { const [open, setOpen] = useState(false); return ( <div className="text-center"> <Button onClick={() => setOpen(true)}>Open Prompt</Button> <Prompt title="Title" subline="Subline" open={open} onClose={() => setOpen(false)} buttons={[ <Button color="danger">Continue</Button>, <Button onClick={() => setOpen(false)}>Cancel</Button>, ]} actions={[<Checkbox>Accept me</Checkbox>]} > <p> Lorem ipsum dolor sit amet consectetur adipisicing elit. Praesentium unde, blanditiis rem accusamus obcaecati enim amet, voluptatibus nemo facilis illum aut itaque in? Deleniti iure amet qui vero, blanditiis quos? </p> </Prompt> </div> ); }; export const PromptWithOnlyOneButton = () => { const [open, setOpen] = useState(false); return ( <div className="text-center"> <Button onClick={() => setOpen(true)}>Open Prompt with only one Button</Button> <Prompt title="Title" subline="Subline" open={open} onClose={() => setOpen(false)} buttons={<Button onClick={() => setOpen(false)}>I understand</Button>} > <p> Lorem ipsum dolor sit amet consectetur adipisicing elit. Praesentium unde, blanditiis rem accusamus obcaecati enim amet, voluptatibus nemo facilis illum aut itaque in? Deleniti iure amet qui vero, blanditiis quos? </p> </Prompt> </div> ); }; export const PromptWithFootnote = () => { const [open, setOpen] = useState(false); return ( <div className="text-center"> <Button onClick={() => setOpen(true)}>Open Prompt with footnote</Button> <Prompt title="Title" subline="Subline" open={open} onClose={() => setOpen(false)} buttons={[ <Button color="danger">Continue</Button>, <Button onClick={() => setOpen(false)}>Cancel</Button>, ]} actions={[<Checkbox>Accept me</Checkbox>]} footnote="This is a footnote" > <p> Lorem ipsum dolor sit amet consectetur adipisicing elit. Praesentium unde, blanditiis rem accusamus obcaecati enim amet, voluptatibus nemo facilis illum aut itaque in? Deleniti iure amet qui vero, blanditiis quos? </p> </Prompt> </div> ); }; export const Basic = () => { const [open, setOpen] = useState(false); return ( <div className="text-center"> <Button onClick={() => setOpen(true)}>Open Basic Modal with only one Button</Button> <BasicModal title="Title" isOpen={open} onClose={() => setOpen(false)} footer={ <> <Button onClick={() => setOpen(false)}>I understand</Button> <Button color="norm" onClick={() => setOpen(false)}> I do not understand </Button> </> } > <p> Lorem ipsum dolor sit amet consectetur adipisicing elit. Praesentium unde, blanditiis rem accusamus obcaecati enim amet, voluptatibus nemo facilis illum aut itaque in? Deleniti iure amet qui vero, blanditiis quos? </p> </BasicModal> </div> ); };
4,559
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Notification.mdx
import { ArgsTable, Canvas, PRIMARY_STORY, Primary, Story } from '@storybook/addon-docs'; # Notification Notifications are most easily used as part of a larger API exposed through the `useNotifications` hook. ## Deduplication Notifications are deduplicated by default based on their `text` value. If a notification is created using a custom notification component, it cannot be deduplicated automatically. To deduplicate custom notifications, pass a unique `key` to the `createNotifaction` call. <Canvas> <Story id="components-notification--basic" /> </Canvas> <div class="hidden"> <Primary /> </div>
4,560
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Notification.stories.tsx
import { ChangeEvent, SetStateAction, useState } from 'react'; import { Button, CircleLoader } from '@proton/atoms'; import { Checkbox, CreateNotificationOptions, CustomNotificationProps, InputFieldTwo, NotificationButton, RadioGroup, useNotifications, } from '@proton/components'; import { getTitle } from '../../helpers/title'; import mdx from './Notification.mdx'; export default { title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; const ExpandableNotification = () => { const [open, setOpen] = useState(false); return ( <> <span>{!open ? 'Expand' : 'Collapse'} me</span> {open && <div style={{ height: 100, width: 100 }}></div>} <NotificationButton onClick={() => setOpen(!open)}>{!open ? 'Expand' : 'Collapse'}</NotificationButton> </> ); }; const CloseableNotification = ({ onClose }: CustomNotificationProps) => { return ( <> <span>I've done the thing</span> <NotificationButton onClick={onClose}>Undo</NotificationButton> </> ); }; const WarningNotification = ({ onClose }: CustomNotificationProps) => { return ( <> <span>Oh no, not again</span> <NotificationButton onClick={onClose}>Edit</NotificationButton> </> ); }; export const Basic = () => { const { createNotification } = useNotifications(); const handleClick = (options: CreateNotificationOptions) => () => { createNotification(options); }; const types = ['info', 'warning'] as const; const BuildYourOwn = () => { const [byoExpiration, setByoExpiration] = useState(5000); const [byoText, setByoText] = useState('Lorem ipsum'); const [byoType, setByoType] = useState<(typeof types)[number]>(types[0]); const [byoCloseButton, setCloseButton] = useState(true); const [byoButtonShow, setByoButtonShow] = useState(false); const [byoButtonText, setByoButtonText] = useState('Undo'); const [byoLoader, setByoLoader] = useState(false); const ByoContent = ({ onClose }: CustomNotificationProps) => { return ( <> <span>{byoText}</span> {byoButtonShow && <NotificationButton onClick={onClose}>{byoButtonText}</NotificationButton>} {byoLoader && <CircleLoader />} </> ); }; return ( <div className="block"> <form> <div className="flex flex-column gap-4 mb-4"> <InputFieldTwo name="content" id="content" label="Content" value={byoText} onChange={(e: { target: { value: SetStateAction<string> } }) => setByoText(e.target.value)} /> <div> <strong className="block mb-4">Type</strong> <RadioGroup name="type" onChange={(v) => setByoType(v)} value={byoType} options={types.map((type) => ({ value: type, label: type }))} /> </div> <Checkbox id="closebutton" checked={byoCloseButton} onChange={() => { setCloseButton(!byoCloseButton); setByoLoader(false); }} > Show Close Button </Checkbox> <Checkbox id="loader" checked={byoLoader} onChange={() => { setByoLoader(!byoLoader); setCloseButton(false); }} > Show Loader </Checkbox> <Checkbox id="byoButtonShow" checked={byoButtonShow} onChange={() => setByoButtonShow(!byoButtonShow)} > Show Button </Checkbox> <InputFieldTwo name="byoButtonText" id="byoButtonText" label="Button Text" className="w-custom" style={{ '--w-custom': '10em' }} value={byoButtonText} onChange={(e: { target: { value: SetStateAction<string> } }) => setByoButtonText(e.target.value) } /> <InputFieldTwo name="expiration" id="expiration" label="Expiration" className="w-custom" style={{ '--w-custom': '10em' }} value={byoExpiration} type="number" onChange={(event: ChangeEvent<HTMLInputElement>) => setByoExpiration(Number(event.target.value)) } /> </div> <Button onClick={handleClick({ key: byoText, type: byoType, text: <ByoContent />, showCloseButton: byoCloseButton, expiration: byoExpiration, })} className="mr-4 mb-4" > Trigger </Button> </form> </div> ); }; return ( <div> <h4 className="mb-4">Presets</h4> <Button color="success" onClick={handleClick({ type: 'success', text: 'You did it', })} className="mr-4 mb-4" > Default notification </Button> <Button color="info" onClick={handleClick({ key: 'close', type: 'info', text: <CloseableNotification /> })} className="mr-4 mb-4" > Default with action </Button> <Button color="info" onClick={handleClick({ type: 'info', text: 'whoop', showCloseButton: false })} className="mr-4 mb-4" > Default without close button </Button> <Button color="info" onClick={handleClick({ key: 'close2', type: 'info', text: <CloseableNotification />, showCloseButton: false, })} className="mr-4 mb-4" > Default without close button but with an action </Button> <Button color="success" onClick={handleClick({ key: 'spinner', type: 'success', showCloseButton: false, text: ( <> Doing the thing... <CircleLoader /> </> ), })} className="mr-4 mb-4" > Default with spinner </Button> <Button color="warning" onClick={handleClick({ type: 'warning', text: 'Uh oh', })} className="mr-4 mb-4" > Default warning </Button> <Button color="warning" onClick={handleClick({ key: 'warning', type: 'warning', text: <WarningNotification /> })} className="mr-4 mb-4" > Warning with action </Button> <Button color="warning" onClick={handleClick({ key: 'warning2', type: 'warning', text: 'Dammit', showCloseButton: false })} className="mr-4 mb-4" > Warning without close button </Button> <Button color="warning" onClick={handleClick({ key: 'warning3', type: 'warning', text: <WarningNotification />, showCloseButton: false, })} className="mr-4 mb-4" > Warning without close button but with an action </Button> <Button color="info" onClick={handleClick({ key: 'expandable', type: 'info', text: <ExpandableNotification />, expiration: -1, })} className="mr-4 mb-4" > Expandable notification </Button> <hr /> <h4 className="mb-4">Build your own</h4> <BuildYourOwn /> </div> ); }; export const Expiration = () => { const { createNotification } = useNotifications(); const handleClick = (options: CreateNotificationOptions) => () => { createNotification(options); }; return ( <div> <Button onClick={handleClick({ type: 'info', text: 'I expire after 5 seconds!', expiration: 3000 })} className="mr-4 mb-4" > Expires after 3 seconds </Button> <Button onClick={handleClick({ type: 'info', text: 'I expire after 500 milliseconds!', expiration: 500 })} className="mr-4 mb-4" > Expires after 500 milliseconds </Button> </div> ); };
4,561
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Price.mdx
import { ArgsTable, Canvas, Primary, Story } from '@storybook/addon-docs'; import { Price } from '@proton/components'; # Price `Price` component helps to display a price in different currencies. ### Basic `Price` supports `EUR | USD | CHF`. Amount coming from the API are always coming in cents. `amount`, `currency`, `integer` and `decimal` parts are splitted to facilitate CSS customization. <Canvas withSource="open"> <Story id="components-price--basic" /> </Canvas> <div class="hidden"> <Primary /> </div> <ArgsTable of={Price} />
4,562
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Price.stories.tsx
import { Price } from '@proton/components'; import { getTitle } from '../../helpers/title'; import mdx from './Price.mdx'; export default { component: Price, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; export const Basic = () => ( <> <ul> <li> <Price currency="EUR">{6699}</Price> </li> <li> <Price currency="CHF">{7699}</Price> </li> <li> <Price currency="USD">{8699}</Price> </li> </ul> </> );
4,563
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Progress.mdx
import { ArgsTable, Canvas, Primary, Story } from '@storybook/addon-docs'; import { Progress } from '@proton/components'; # Progress `Progress` represents the completion progress of a task. This component is not suitable for representing a gauge (e.g. disk space usage or relevance of a query result). To represent a gauge, use the [Meter](?path=/docs/components-meter--basic) component instead. ### Basic Update the `value` attribute of the progress bar and the text explaining the action in progress. <Canvas withSource="open"> <Story id="components-progress--basic" /> </Canvas> <div class="hidden"> <Primary /> </div> <ArgsTable of={Progress} />
4,564
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Progress.stories.tsx
import { useEffect, useState } from 'react'; import { Progress } from '@proton/components'; import { getTitle } from '../../helpers/title'; import mdx from './Progress.mdx'; export default { component: Progress, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; export const Basic = () => { const [value, setValue] = useState(0); const increment = () => setValue(value + 5); const className = value < 50 ? 'progress-bar--warning' : 'progress-bar--error'; useEffect(() => { const intervalID = setInterval(increment, 5000); return () => { clearInterval(intervalID); }; }, []); return <Progress value={value} className={className} />; };
4,565
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/PromotionButton.mdx
import { ArgsTable, Canvas, PRIMARY_STORY, Primary, Story } from '@storybook/addon-docs'; import { Alert, InlineLinkButton } from '@proton/components'; # Promotion Button ```js import { PromotionButton } from '@proton/components'; ``` The promotion button is like a normal button but cooler and with gradients <Canvas> <Story id="components-promotion-button--example" /> </Canvas> <Canvas> <Story id="components-promotion-button--example-with-icon" /> </Canvas> <Canvas> <Story id="components-promotion-button--example-icon-only" /> </Canvas> <Canvas> <Story id="components-promotion-button--example-icon-small" /> </Canvas> <Canvas> <Story id="components-promotion-button--example-with-icon-no-gradient" /> </Canvas> <Canvas> <Story id="components-promotion-button--example-like" /> </Canvas>
4,566
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/PromotionButton.stories.tsx
import { ButtonLike } from '@proton/atoms'; import { PromotionButton } from '@proton/components/components/button/PromotionButton'; import mdx from './PromotionButton.mdx'; export default { component: PromotionButton, title: 'components/Promotion Button', parameters: { docs: { page: mdx, }, }, }; export const Example = () => <PromotionButton>Regular</PromotionButton>; export const ExampleWithIcon = () => ( <PromotionButton iconName="brand-proton-mail-filled-plus">With Icon</PromotionButton> ); export const ExampleIconOnly = () => ( <PromotionButton iconName="upgrade" icon={true} shape="ghost"> Icon Ghost </PromotionButton> ); export const ExampleIconSmall = () => ( <PromotionButton iconName="brand-proton-mail-filled-plus" icon={true} upsell> Upsell </PromotionButton> ); export const ExampleWithIconNoGradient = () => ( <PromotionButton iconName="brand-proton-mail-filled-plus" iconGradient={false}> No icon gradient </PromotionButton> ); export const ExampleLike = () => <ButtonLike as={PromotionButton}>ButtonLike</ButtonLike>; export const Basic = ({ ...args }) => ( <PromotionButton icon={true} iconName="users-plus" {...args}> Loremium </PromotionButton> ); Basic.args = {};
4,567
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/QuickSettings.mdx
import { ArgsTable, Canvas, PRIMARY_STORY, Primary, Story } from '@storybook/addon-docs'; import { DefaultQuickSettings, QuickSettingsMain, QuickSettingsSection, QuickSettingsSectionHeadline, QuickSettingsSectionRow, } from '@proton/components/components/drawer/views/quickSettings'; # QuickSettings The QuickSettings are shown in the Drawer. QuickSettings can be added using `QuickSettingsSection` and `QuickSettingsSectionRow` in combination with the existing `Toggle` and `Select` components. <Canvas withSource="open"> <Story id="components-quicksettings--basic" /> </Canvas> <ArgsTable story={PRIMARY_STORY} />
4,568
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/QuickSettings.stories.tsx
import { useState } from 'react'; import { Button } from '@proton/atoms/Button'; import { Info, Option, SelectTwo, Toggle } from '@proton/components/components'; import { QuickSettingsMain, QuickSettingsSection, QuickSettingsSectionHeadline, QuickSettingsSectionRow, } from '@proton/components/components/drawer/views/quickSettings'; import { getTitle } from '../../helpers/title'; import mdx from './QuickSettings.mdx'; export default { component: QuickSettingsMain, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; export const Basic = () => { const [value1, setValue1] = useState('ant'); const [value2, setValue2] = useState('grid'); const [value3, setValue3] = useState('week'); const [isChecked1, setIsChecked1] = useState(true); const [isChecked2, setIsChecked2] = useState(true); return ( <div className="quickSettings py-2" style={{ width: '280px', 'min-height': '400px' }}> <QuickSettingsMain> <QuickSettingsSection> <QuickSettingsSectionRow label="Select" action={ <SelectTwo unstyled originalPlacement="bottom-end" value={value1} onChange={({ value: v }) => setValue1(v)} > <Option title="Ant" value="ant" /> <Option title="Zebra" value="zebra" /> </SelectTwo> } /> </QuickSettingsSection> <QuickSettingsSection> <QuickSettingsSectionRow label="Toggle" labelInfo={<Info title="Optional info tooltip" />} action={ <Toggle id="toggle-basic" checked={isChecked1} onChange={() => { setIsChecked1(!isChecked1); }} /> } /> </QuickSettingsSection> <QuickSettingsSection> <QuickSettingsSectionHeadline>Optional Headline</QuickSettingsSectionHeadline> <QuickSettingsSectionRow label="Layout" action={ <SelectTwo unstyled originalPlacement="bottom-end" value={value2} onChange={({ value: v }) => setValue2(v)} > <Option title="Grid" value="grid" /> <Option title="Row" value="row" /> </SelectTwo> } /> <QuickSettingsSectionRow label="View" action={ <SelectTwo unstyled originalPlacement="bottom-end" value={value3} onChange={({ value: v }) => setValue3(v)} > <Option title="Day" value="day" /> <Option title="Week" value="week" /> <Option title="Month" value="month" /> </SelectTwo> } /> <QuickSettingsSectionRow label="Toggle" action={ <Toggle id="toggle-basic2" checked={isChecked2} onChange={() => { setIsChecked2(!isChecked2); }} /> } /> </QuickSettingsSection> <Button onClick={() => {}} className="flex-item-noshrink text-sm mx-auto" shape="ghost" color="norm"> Action </Button> </QuickSettingsMain> </div> ); };
4,569
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Radio.mdx
import { ArgsTable, Canvas, PRIMARY_STORY, Primary, Story } from '@storybook/addon-docs'; # Radio Radio inputs allow the user to select one item from a set. <Canvas withSource="open"> <Story id="components-radio--basic" /> </Canvas> <div class="hidden"> <Primary /> </div> <ArgsTable story={PRIMARY_STORY} />
4,570
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Radio.stories.tsx
import { useState } from 'react'; import { Radio, RadioGroup } from '@proton/components'; import { getTitle } from '../../helpers/title'; import mdx from './Radio.mdx'; export default { component: Radio, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; const weather = ['Snow', 'Sunshine', 'Rain'] as const; export const Basic = () => { const [selectedColor, setSelectedColor] = useState<(typeof weather)[number] | undefined>(undefined); return ( <div> <RadioGroup name="selected-weather" onChange={(v) => setSelectedColor(v)} value={selectedColor} options={weather.map((option) => ({ value: option, label: option }))} /> </div> ); };
4,571
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Scale.mdx
import { ArgsTable, Canvas, Primary, Story } from '@storybook/addon-docs'; import { Scale } from '@proton/components'; # Scale `Scale` is a wrapper around [InputButton](?path=/docs/components-inputbutton--basic). A radio button numeric input implementation together with labels. ### Basic <Canvas withSource="open"> <Story id="components-scale--basic" /> </Canvas> ### Emoji <Canvas> <Story id="components-scale--emoji" /> </Canvas> <div class="hidden"> <Primary /> </div> <ArgsTable of={Scale} />
4,572
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Scale.stories.tsx
import { useState } from 'react'; import { EmojiScale, Scale } from '@proton/components'; import { getTitle } from '../../helpers/title'; import mdx from './Scale.mdx'; export default { component: Scale, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; export const Basic = () => { const [value, setValue] = useState<number>(); const handleChange = (v: number) => { setValue(v); }; return ( <Scale from={0} to={10} fromLabel="0 - Not at all likely" toLabel="10 - Extremely likely" value={value} onChange={handleChange} /> ); }; export const Emoji = () => { const [value, setValue] = useState<number>(); const handleChange = (v: number) => { setValue(v); }; return <EmojiScale fromLabel="Awful" toLabel="Wonderful" value={value} onChange={handleChange} />; };
4,573
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Select.mdx
import { ArgsTable, Canvas, Meta, PRIMARY_STORY, Primary, Story } from '@storybook/addon-docs'; import { SelectTwo } from '@proton/components'; import { SearchableSelect } from '@proton/components'; # Select The Select component allows a user to select from a list of options. In line with trying to emulate the native os `<select />`s as well as possible, this Select component implements keyboard navigation in line with the behaviour of OSX' native `<select />` implementation, including keyboard searchability which resets a given search-input after a timeout (configurable through the `clearSearchAfter` prop). ### Basic Select The most basic usage of the Select component comes in the form of using just strings as both the value of the option as well as the contents of the option. <Canvas withSource="open"> <Story id="components-select--basic" /> </Canvas> ### Select multiple options We can allow the user to select multiple options by specifying the `mode` prop and ensuring the `value` prop is a list. Dropdown items become togglable & selecting an item will not auto-close the dropdown. <Canvas> <Story id="components-select--multiple" /> </Canvas> ### Rich option content Any rich option content is supported through React's `children` api as the following example demonstrates by using icons inside the children of the `<Option />` component's children prop. <Canvas> <Story id="components-select--with-rich-option-content" /> </Canvas> ### Complex values As opposed to native selects, this Select component allows for `<Option />` values to be of complex types (e.g. `Object`). ** Important note ** Under the hood, `Select` uses reference equality comparisons to determine which options are selected. When using complex values, make sure the `value` prop actually references one of the selected `<Option />` values. _In practice, make sure your options are re-cycled through out render cycles by either wrapping them in a `useRef` or `useMemo` hook._ <Canvas> <Story id="components-select--with-complex-values" /> </Canvas> ### InputField The Select component can be uses as an [input for InputField](/docs/components-inputfield--basic#custom-elements). <Canvas> <Story id="components-select--as-input-field" /> </Canvas> ### Searchable Select This component will add a search input field inside of the select dropdown in order to filter out the options data. You can pass a custom search function if necessary. <Canvas> <Story id="components-select--search" /> </Canvas> ### Searchable & Multiple options Allow searching while selecting multiple results. The selected options are preserved through out the search. Selecting an item will not auto-close the dropdown : each item can be toggled. <Canvas> <Story id="components-select--multi-search" /> </Canvas> ### Custom display value rendering The `renderSelected` prop allows customisation of the rendered display value. <Canvas> <Story id="components-select--render-selected" /> </Canvas> ### Accessibility This component supporting complex values, together with the fact that option contents can be rich in nature causes an uncertainty about which human-readable part of either `value` or `children` can be used for accessibility labels. To make up for this, an API anomaly is introduced for this component making the `title` prop of the option required, however, in the case that you're using Select in it's most basic form (string `value` & string `children`) you're only required to pass `title` & `value`, leaving `children` out (as can be seen in the [Basic Select](#basic-select)) example. <Primary /> <ArgsTable story={PRIMARY_STORY} />
4,574
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Select.stories.tsx
import { useMemo, useRef, useState } from 'react'; import { Icon, InputFieldTwo, LabelStack, Option, SearchableSelect, SelectTwo } from '@proton/components'; import { getTitle } from '../../helpers/title'; import mdx from './Select.mdx'; export default { title: getTitle(__filename, false), component: SelectTwo, parameters: { docs: { page: mdx, }, }, }; export const Playground = ({ ...args }) => { const [value, setValue] = useState('ant'); return ( <SelectTwo {...args} value={value} onChange={({ value: v }) => setValue(v)}> <Option title="Ant" value="ant" /> <Option title="Zebra" value="zebra" /> </SelectTwo> ); }; Playground.args = {}; export const Basic = () => { const [value, setValue] = useState('ant'); return ( <SelectTwo value={value} onValue={setValue}> <Option title="Ant" value="ant" /> <Option title="Zebra" value="zebra" /> </SelectTwo> ); }; export const Multiple = () => { const options = useMemo(() => [{ label: 'ant' }, { label: 'zebra' }], []); const [value, setValue] = useState([options[0]]); return ( <SelectTwo value={value} onValue={setValue} multiple> {options.map((option) => ( <Option title={option.label} value={option} key={option.label} /> ))} </SelectTwo> ); }; export const Search = () => { const options = ['France', 'Switzerland', 'Taïwan', 'USA', 'UK']; const [value, setValue] = useState('France'); return ( <SearchableSelect title={'Choose your country'} value={value} onChange={(e) => setValue(e.value)} search searchPlaceholder={'Search for country'} > {options.map((option) => ( <Option key={option} value={option} title={option} /> ))} </SearchableSelect> ); }; export const MultiSearch = () => { const options = ['France', 'Switzerland', 'Taïwan', 'USA', 'UK']; const [value, setValue] = useState([]); return ( <SearchableSelect multiple value={value} onChange={(e) => setValue(e.value)} search searchPlaceholder={'Search for country'} placeholder={'Choose your country'} > {options.map((option) => ( <Option key={option} value={option} title={option} /> ))} </SearchableSelect> ); }; const options = [ { color: '#8080FF', name: 'electron' }, { color: '#EC3E7C', name: 'muon' }, { color: '#DB60D6', name: 'tau' }, { color: '#415DF0', name: 'neutrino' }, { color: '#179FD9', name: 'z boson' }, { color: '#1DA583', name: 'w boson' }, { color: '#3CBB3A', name: 'quark' }, { color: '#B4A40E', name: 'higgs' }, { color: '#936D58', name: 'photon' }, { color: '#F78400', name: 'gluon' }, ]; export const RenderSelected = () => { const [value, setValue] = useState<typeof options>(options.slice(0, 4)); return ( <SelectTwo multiple value={value} placeholder={'Choose your country'} onValue={setValue} renderSelected={(selected) => <LabelStack labels={selected ?? []} />} > {options.map((option) => ( <Option key={option.name} value={option} title={option.name} /> ))} </SelectTwo> ); }; export const ControlledOpenState = () => { const [value, setValue] = useState(''); const [open, setOpen] = useState(false); function handleOpen() { setOpen(true); } function handleClose() { setOpen(false); } return ( <SelectTwo isOpen={open} value={value} onChange={({ value: v }) => setValue(v)} onOpen={handleOpen} onClose={handleClose} > <Option title="Ant" value="ant" /> <Option title="Zebra" value="zebra" /> </SelectTwo> ); }; export const WithRichOptionContent = () => { const [value, setValue] = useState('android'); return ( <SelectTwo value={value} onChange={({ value: v }) => setValue(v)}> <Option title="android" value="android"> <Icon name="brand-android" /> android </Option> <Option title="apple" value="apple"> <Icon name="brand-apple" /> apple </Option> <Option title="linux" value="linux"> <Icon name="brand-linux" /> linux </Option> <Option title="chrome" value="chrome"> <Icon name="brand-chrome" /> chrome </Option> </SelectTwo> ); }; export const WithCustomSearchClearTimer = () => { const [value, setValue] = useState('ant'); return ( <SelectTwo value={value} onChange={({ value: v }) => setValue(v)} clearSearchAfter={1000}> <Option title="Ant" value="ant" /> <Option title="Bear" value="bear" /> <Option title="Chimpanzee" value="chimpanzee" /> <Option title="Deer" value="deer" /> <Option title="Zebra" value="zebra" /> </SelectTwo> ); }; export const WithComplexValues = () => { /* * The useRef is used here in order to preserve identity of the value to its * option between render cycles since the Select uses identity comparison to * determine which option is selected. */ const { current: options } = useRef([{ name: 'ant' }, { name: 'bear' }, { name: 'chimpanzee' }]); const [value, setValue] = useState<{ name: string } | null>(options[0]); return ( <SelectTwo value={value} onChange={({ value: v }) => setValue(v)}> {options.map((option) => ( <Option title={option.name} value={option} key={option.name} /> ))} </SelectTwo> ); }; export const AsInputField = () => { return ( <InputFieldTwo as={SelectTwo} label="Select" placeholder="Placeholder"> <Option title="one" value="one" /> <Option title="two" value="two" /> <Option title="three" value="three" /> </InputFieldTwo> ); };
4,575
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Spotlight.mdx
import { Canvas, Primary, Story } from '@storybook/addon-docs'; # Spotlight A dedicated Tooltip / Dropdown like used to put a spotlight on a new feature Known issue: the spotlight doesn't deal with dynamic positioning, perhaps it might be needed in the future. Yet you may experience it a lot in Storybook. Also, changing the positioning will always re-open the spotlight <Primary />
4,576
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Spotlight.stories.tsx
import { useEffect, useState } from 'react'; import { PopperPlacement, RadioGroup, Spotlight, allPopperPlacements } from '@proton/components'; import { getTitle } from '../../helpers/title'; import mdx from './Spotlight.mdx'; export default { component: Spotlight, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; const sizeOptions = [ { value: '2px', label: '2px' }, { value: '8px', label: '8px' }, { value: '14px', label: '14px' }, ]; const placementOptions = allPopperPlacements.map((placement) => ({ value: placement, label: placement, })); export const Sandbox = () => { const [targetSize, setTargetSize] = useState(sizeOptions[1].value); const [placement, setPlacement] = useState<PopperPlacement>(allPopperPlacements[0]); const [show, setShow] = useState(false); useEffect(() => { setTimeout(() => setShow(true), 500); }, []); const handleChangeSize = (size: string) => { setShow(false); setTargetSize(size); setTimeout(() => setShow(true), 100); }; const handleChangePlacement = (placement: PopperPlacement) => { setShow(false); setPlacement(placement); setTimeout(() => setShow(true), 100); }; const style = { width: '8em', height: '8em', margin: '15em', padding: '1em', fontSize: targetSize, }; return ( <div className="p-7"> <div className="flex flex-align-items-stretch"> <div className="mr-8"> <strong className="block mb-4">Target size</strong> <RadioGroup name="target-size" onChange={handleChangeSize} value={targetSize} options={sizeOptions} /> </div> <div className="mr-8"> <strong className="block mb-4">Placement</strong> <RadioGroup name="placement" onChange={handleChangePlacement} value={placement} options={placementOptions} /> </div> <div className="flex flex-item-fluid flex-align-items-center flex-justify-center border"> <Spotlight content="Content of the spotlight" show={show} originalPlacement={placement} key={placement} > <div className="border rounded flex flex-align-items-center flex-justify-center" style={style}> Something to put spotlight on </div> </Spotlight> </div> </div> </div> ); };
4,577
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Table.mdx
import { ArgsTable, Canvas, Primary, Story } from '@storybook/addon-docs'; import { Table } from '@proton/components'; # Table Use the `Table` component for tabular data. Add the `hasAction` prop to automatically align the last column to the right. <Canvas withSource="open"> <Story id="components-table--basic" /> </Canvas> ## Responsive To optimize a table, add `responsive="cards"` and add a headline as `label` prop to each table cell. The labels are indepentent from the table header cells and can be omitted if the cell content makes sense without headline (like "Action" or "Status") <div className="border p-2 rounded bg-weak" style={{ width: '360px', resize: 'both', overflow: 'auto' }}> <Story id="components-table--cards" /> </div> ### Props <ArgsTable of={Table} />
4,578
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Table.stories.tsx
import { Button } from '@proton/atoms'; import { Table, TableBody, TableCell, TableHeader, TableHeaderCell, TableRow } from '@proton/components'; import { getTitle } from '../../helpers/title'; import mdx from './Table.mdx'; export default { title: getTitle(__filename, false), component: Table, subcomponents: { TableHeader, TableHeaderCell, TableRow, TableCell, TableBody }, parameters: { docs: { page: mdx, inlineStories: false, }, }, }; export const Basic = () => { return ( <Table responsive="cards" hasActions> <TableHeader> <TableHeaderCell>ID</TableHeaderCell> <TableHeaderCell>Name</TableHeaderCell> <TableHeaderCell>Action</TableHeaderCell> </TableHeader> <TableBody> <TableRow> <TableCell label="ID">Lorem ipsum</TableCell> <TableCell label="Name">Lorem ipsum</TableCell> <TableCell> <Button size="small">Loremium</Button> </TableCell> </TableRow> <TableRow> <TableCell label="ID">Lorem ipsum</TableCell> <TableCell label="Name">Lorem ipsum</TableCell> <TableCell> <Button size="small">Loremium</Button> </TableCell> </TableRow> <TableRow> <TableCell label="ID">Lorem ipsum</TableCell> <TableCell label="Name">Lorem ipsum</TableCell> <TableCell> <Button size="small">Loremium</Button> </TableCell> </TableRow> </TableBody> </Table> ); }; Basic.parameters = { docs: { iframeHeight: '300px', }, }; export const Cards = () => { return ( <Table responsive="cards"> <TableHeader> <TableHeaderCell>ID</TableHeaderCell> <TableHeaderCell>Name</TableHeaderCell> <TableHeaderCell>Action</TableHeaderCell> </TableHeader> <TableBody> <TableRow> <TableCell label="ID">Lorem ipsum</TableCell> <TableCell label="Name">Lorem ipsum</TableCell> <TableCell> <Button size="small">Settings</Button> </TableCell> </TableRow> <TableRow> <TableCell label="ID">Lorem ipsum</TableCell> <TableCell label="Name">Lorem ipsum</TableCell> <TableCell> <Button size="small">Settings</Button> </TableCell> </TableRow> <TableRow> <TableCell label="ID">Lorem ipsum</TableCell> <TableCell label="Name">Lorem ipsum</TableCell> <TableCell> <Button size="small">Settings</Button> </TableCell> </TableRow> </TableBody> </Table> ); }; Cards.parameters = { docs: { iframeHeight: '500px', }, };
4,579
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Tabs.mdx
import { ArgsTable, Canvas, Primary, Story } from '@storybook/addon-docs'; import { Tabs } from '@proton/components'; # Tabs Simple responsive horizontal navigation tabs. `Tabs` organize and allow navigation between groups of content that are related and at the same level of hierarchy. - The link between tabs and tab panels using `aria-controls` and `aria-labelledby`. - The use of `role="tablist/presentation/tab/tabpanel"`. - A selected tab has `aria-selected="true"`, `aria-selected="false"` if not. <Canvas withSource="open"> <Story id="components-tabs--basic" /> </Canvas> ## Sandbox <Story id="components-tabs--sandbox" /> ### Props <div class="hidden"> <Primary /> </div> <ArgsTable of={Tabs} />
4,580
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Tabs.stories.tsx
import { useState } from 'react'; import { Checkbox, Tabs } from '@proton/components'; import bulbasaur from '../../assets/bulbasaur.png'; import charmander from '../../assets/charmander.png'; import squirtle from '../../assets/squirtle.png'; import { getTitle } from '../../helpers/title'; import mdx from './Tabs.mdx'; export default { title: getTitle(__filename, false), component: Tabs, parameters: { docs: { page: mdx, }, }, }; export const Basic = () => { const tabs = [ { title: 'Bulbasaur', content: ( <> <img src={bulbasaur} alt="Bulbasaur" /> <p> There is a plant seed on its back right from the day this Pokémon is born. The seed slowly grows larger. </p> </> ), }, { title: 'Charmander', content: ( <> <img src={charmander} alt="Charmander" /> <p> It has a preference for hot things. When it rains, steam is said to spout from the tip of its tail. </p> </> ), }, { title: 'Squirtle', content: ( <> <img src={squirtle} alt="Squirtle" /> <p>When it retracts its long neck into its shell, it squirts out water with vigorous force.</p> </> ), }, ]; const [index, setIndex] = useState(0); return <Tabs tabs={tabs} value={index} onChange={setIndex} />; }; const toggles = ['fullWidth', 'stickyTabs'] as const; export const Sandbox = () => { const [selectedToggles, setSelectedToggles] = useState(toggles.map(() => false)); const [index, setIndex] = useState(0); const tabs = [ { title: 'Bulbasaur', content: ( <> <p> There is a plant seed on its back right from the day this Pokémon is born. The seed slowly grows larger. There is a plant seed on its back right from the day this Pokémon is born. The seed slowly grows larger. There is a plant seed on its back right from the day this Pokémon is born. The seed slowly grows larger. There is a plant seed on its back right from the day this Pokémon is born. The seed slowly grows larger. There is a plant seed on its back right from the day this Pokémon is born. The seed slowly grows larger. There is a plant seed on its back right from the day this Pokémon is born. The seed slowly grows larger. There is a plant seed on its back right from the day this Pokémon is born. The seed slowly grows larger. There is a plant seed on its back right from the day this Pokémon is born. The seed slowly grows larger. There is a plant seed on its back right from the day this Pokémon is born. The seed slowly grows larger. There is a plant seed on its back right from the day this Pokémon is born. The seed slowly grows larger. There is a plant seed on its back right from the day this Pokémon is born. The seed slowly grows larger. There is a plant seed on its back right from the day this Pokémon is born. The seed slowly grows larger. There is a plant seed on its back right from the day this Pokémon is born. The seed slowly grows larger. There is a plant seed on its back right from the day this Pokémon is born. The seed slowly grows larger. There is a plant seed on its back right from the day this Pokémon is born. The seed slowly grows larger. There is a plant seed on its back right from the day this Pokémon is born. The seed slowly grows larger. There is a plant seed on its back right from the day this Pokémon is born. The seed slowly grows larger. There is a plant seed on its back right from the day this Pokémon is born. The seed slowly grows larger. Sorry, I needed more text. </p> </> ), }, { title: 'Charmander', content: ( <> <p> It has a preference for hot things. When it rains, steam is said to spout from the tip of its tail. </p> </> ), }, { title: 'Squirtle', content: ( <> <p>When it retracts its long neck into its shell, it squirts out water with vigorous force.</p> </> ), }, ]; const tabsExample = ( <Tabs tabs={tabs} value={index} onChange={setIndex} className="scroll-if-needed max-h-custom" {...selectedToggles.reduce<{ [key: string]: boolean }>((acc, value, i) => { acc[toggles[i]] = value; return acc; }, {})} ></Tabs> ); return ( <div> <div style={{ '--max-h-custom': '10rem' }}>{tabsExample}</div> <div className="mt-8 mb-14"> <strong className="block mb-4">Toggles</strong> {toggles.map((prop, i) => { return ( <div className="mb-2"> <Checkbox checked={selectedToggles[i]} onChange={({ target: { checked } }) => { setSelectedToggles( selectedToggles.map((oldValue, otherIndex) => otherIndex === i ? checked : oldValue ) ); }} > {prop} </Checkbox> </div> ); })} </div> </div> ); };
4,581
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Toggle.mdx
import { ArgsTable, Canvas, PRIMARY_STORY, Primary, Story } from '@storybook/addon-docs'; # Toggle `Toggle` is a simple component used for activating one of two predefined options. Commonly used as an on/off button. <Canvas withSource="open"> <Story id="components-toggle--basic" /> </Canvas> ## With label Add a child element to display a default label <Canvas> <Story id="components-toggle--label" /> </Canvas> ### Loading state By using the `loading` prop, it displays a loader and automatically blocks the interaction with the `Toggle` component. <Canvas> <Story id="components-toggle--loading" /> </Canvas> ### Disabled state Add the `disabled` prop to the `Toggle` component to automatically style and block interaction. <Canvas> <Story id="components-toggle--disabled" /> </Canvas> ### InputField The Toggle component can be used as an [input for InputField](/docs/components-inputfield--basic#custom-elements). <Canvas> <Story id="components-toggle--as-input-field" /> </Canvas> ### Props <div class="hidden"> <Primary /> </div> <ArgsTable story={PRIMARY_STORY} />
4,582
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Toggle.stories.tsx
import { useState } from 'react'; import { InputFieldTwo, Toggle } from '@proton/components'; import { useLoading } from '@proton/hooks'; import { wait } from '@proton/shared/lib/helpers/promise'; import { getTitle } from '../../helpers/title'; import mdx from './Toggle.mdx'; export default { component: Toggle, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; export const Basic = () => { const [isChecked, setIsChecked] = useState(true); return ( <Toggle id="toggle-basic" checked={isChecked} onChange={() => { setIsChecked(!isChecked); }} /> ); }; export const Label = () => { const [isChecked, setIsChecked] = useState(true); return ( <> <Toggle id="toggle-label" checked={isChecked} onChange={() => { setIsChecked(!isChecked); }} > This is a label </Toggle> </> ); }; export const Loading = () => { const [isChecked, setIsChecked] = useState(false); const [loading, withLoading] = useLoading(false); return ( <Toggle id="toggle-loading" checked={isChecked} loading={loading} onChange={() => { const run = async () => { await wait(500); setIsChecked((old) => !old); }; void withLoading(run()); }} /> ); }; export const Disabled = () => { return ( <> <Toggle id="toggle-disabled-unchecked" disabled className="mr-4" /> <Toggle id="toggle-disabled-checked" checked disabled /> </> ); }; export const AsInputField = () => { const [checked, setChecked] = useState(false); return <InputFieldTwo as={Toggle} label="Toggle" checked={checked} onChange={() => setChecked(!checked)} />; };
4,583
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/TopBanner.mdx
import { ArgsTable, Canvas, PRIMARY_STORY, Primary, Story } from '@storybook/addon-docs'; # Top banner Simple component used to display status at the top of the page. <Canvas> <Story id="components-topbanner--basic" /> </Canvas> ## On close A close button (x) is displayed when a on close method is passed as props, this allow users to manually close the top banner. <Canvas> <Story id="components-topbanner--close" /> </Canvas> ## Backround color The top banner can takes a className props, this is what is used define the background color of the banner. <Canvas> <Story id="components-topbanner--color" /> </Canvas>
4,584
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/TopBanner.stories.tsx
import { TopBanner } from '@proton/components'; import { getTitle } from '../../helpers/title'; import mdx from './TopBanner.mdx'; export default { component: TopBanner, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; export const Basic = () => { return <TopBanner className="bg-danger">Example of a top banner</TopBanner>; }; export const Close = () => { return ( <TopBanner className="bg-danger" onClose={() => alert('Close button pressed')}> Example of a top banner with close button </TopBanner> ); }; export const Color = () => { return ( <div className="flex flex-column gap-2"> <TopBanner className="bg-norm">Banner with norm background</TopBanner> <TopBanner className="bg-weak">Banner with weak background</TopBanner> <TopBanner className="bg-strong">Banner with strong background</TopBanner> <TopBanner className="bg-primary">Banner with primary background</TopBanner> <TopBanner className="bg-danger">Banner with danger background</TopBanner> <TopBanner className="bg-warning">Banner with warning background</TopBanner> <TopBanner className="bg-success">Banner with success background</TopBanner> <TopBanner className="bg-info">Banner with info background</TopBanner> <TopBanner>Banner with no background</TopBanner> </div> ); };
4,585
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/TotpInput.mdx
import { ArgsTable, Canvas, PRIMARY_STORY, Primary, Story } from '@storybook/addon-docs'; # TotpInput `TotpInput` is a component to simplify inputs of one-time password codes. It is dynamic and takes the available width. <Canvas withSource="open"> <Story id="components-totpinput--basic" /> </Canvas> ### Length It supports setting the number of inputs to have with the `length` property: <Canvas> <Story id="components-totpinput--length" /> </Canvas> ### Type Add the type property with `number` or `alphabet` to customise valid input values. <Canvas> <Story id="components-totpinput--type" /> </Canvas> <div class="hidden"> <Primary /> </div> <ArgsTable story={PRIMARY_STORY} />
4,586
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/TotpInput.stories.tsx
import { useState } from 'react'; import { InlineLinkButton, TotpInput } from '@proton/components'; import { getTitle } from '../../helpers/title'; import mdx from './TotpInput.mdx'; export default { component: TotpInput, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; export const Basic = () => { const [value, setValue] = useState(''); return <TotpInput value={value} length={6} onValue={setValue} type="number" />; }; export const Length = () => { const [value, setValue] = useState('1a2b'); return <TotpInput value={value} length={4} onValue={setValue} type="alphabet" />; }; export const Type = () => { const [value, setValue] = useState(''); const [type, setType] = useState<'number' | 'alphabet'>('alphabet'); return ( <> <TotpInput value={value} length={type === 'alphabet' ? 8 : 6} onValue={setValue} type={type} /> <InlineLinkButton className="mt-4" onClick={() => { setType(type === 'alphabet' ? 'number' : 'alphabet'); }} > {type === 'alphabet' ? 'Use type `number`' : 'Use type `alphabet`'} </InlineLinkButton> </> ); };
4,587
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Upsell.mdx
import { ArgsTable, Canvas, PRIMARY_STORY, Primary, Story } from '@storybook/addon-docs'; # Upsell The Upsell feature has its own content like specific icons or features list. ## Icon <Canvas> <Story id="components-upsell--icon" /> </Canvas> ## Modal <Canvas> <Story id="components-upsell--basic" /> </Canvas>
4,588
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/Upsell.stories.tsx
import { useState } from 'react'; import { Button } from '@proton/atoms/Button'; import { Checkbox, UpsellModal } from '@proton/components/components'; import UpsellIcon from '@proton/components/components/upsell/UpsellIcon'; import { UpsellModalProps } from '@proton/components/components/upsell/modal/UpsellModal'; import { upsellFeatures } from '@proton/components/components/upsell/modal/constants'; import { getTitle } from '../../helpers/title'; import mdx from './Upsell.mdx'; export default { title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; export const Icon = () => { return <UpsellIcon />; }; export const Basic = () => { const [opened, setOpened] = useState(false); const [selectedFeatures, setSelectedFeatures] = useState<UpsellModalProps['features']>([ 'auto-delete-trash-and-spam', ]); return ( <div className="flex flex-align-items-stretch flex-justify-space-between py-7"> <div className="w-1/2"> <strong className="block mb-4">Upsell Features</strong> <ul className="unstyled"> {Object.entries(upsellFeatures).map(([fakeKey, feature]) => { const key = fakeKey as unknown as UpsellModalProps['features'][number]; return ( <li> <Checkbox name="selected-color" onChange={() => { if (selectedFeatures.includes(key)) { const nextSelected = selectedFeatures.filter((f) => f !== key); setSelectedFeatures(nextSelected); } else { const nextSelected = [...selectedFeatures, key]; setSelectedFeatures(nextSelected); } }} value={key} checked={selectedFeatures.includes(key)} > {feature.getText()} </Checkbox> </li> ); })} </ul> </div> <div className=""> <UpsellModal modalProps={{ key: 'upsell', onClose: () => { setOpened(false); }, onExit: () => { setOpened(false); }, open: opened, }} description={'A description to write'} features={selectedFeatures} title="A title" upsellRef="account-banner" /> <Button className="mx-auto" size="large" fullWidth color="norm" onClick={() => { setOpened(!opened); }} > {'Open'} </Button> </div> </div> ); };
4,589
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/VideoInstructions.mdx
import { ArgsTable, Canvas, Primary, Story } from '@storybook/addon-docs'; import { VideoInstructions } from '@proton/components'; # VideoInstructions `VideoInstructions` is a simple component used to display a video that will automatically play and that you can replay via the `replay` button. It is particularly useful for in-app instructions videos. You should provide sources for the video in `webm` and `mp4` format. <Canvas withSource="open"> <Story id="components-videoinstructions--basic" /> </Canvas> ### Props <div class="hidden"> <Primary /> </div> <ArgsTable of={VideoInstructions} />
4,590
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/components/VideoInstructions.stories.tsx
import { VideoInstructions } from '@proton/components'; import videoMp4 from '../../assets/videos/oauth-instructions.mp4'; import videoWebm from '../../assets/videos/oauth-instructions.webm'; import { getTitle } from '../../helpers/title'; import mdx from './VideoInstructions.mdx'; export default { component: VideoInstructions, title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; export const Basic = () => { return ( <div className="max-w-custom m-auto" style={{ '--max-w-custom': '50em' }}> <VideoInstructions> <source src={videoWebm} type="video/webm" /> <source src={videoMp4} type="video/mp4" /> </VideoInstructions> </div> ); };
4,591
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/coreConcepts/Colors.mdx
import { Canvas, ColorItem, ColorPalette, Primary, Story } from '@storybook/addon-docs'; import { Alert } from '@proton/components'; # Colors <Alert type="warning"> This page is only intended to give a overview of all colors in the different themes. Not all colors are to be used in development. Please refer to <a href="?path=/docs/core-concepts-theming-taxonomy--page">theming taxonomy</a> for usage of css variables and <a href="?path=/docs/css-utilities-colors--background-colors">color helpers</a> for an over of available CSS utility classes. </Alert> ## Base Colors On Standard Background <Story id="core-concepts-colors--base-standard" /> ## Base Colors On Prominent Background <Story id="core-concepts-colors--base-prominent" /> <div class="hidden"> <Primary /> </div>
4,592
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/coreConcepts/Colors.stories.tsx
import { ColorItem, ColorPalette } from '@storybook/addon-docs'; import { getTitle } from '../../helpers/title'; import mdx from './Colors.mdx'; export default { title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; const BaseColors = () => ( <> <ColorPalette> <ColorItem title="Primary" subtitle="Protons primary color" colors={['var(--primary)', 'var(--primary-contrast)']} /> <ColorItem title="Background" subtitle="Theme background colors" colors={[ 'var(--background-norm)', 'var(--background-weak)', 'var(--background-strong)', 'var(--background-invert)', ]} /> <ColorItem title="Text" subtitle="Theme text colors" colors={[ 'var(--text-norm)', 'var(--text-weak)', 'var(--text-hint)', 'var(--text-disabled)', 'var(--text-invert)', ]} /> <ColorItem title="Border" subtitle="Theme border colors" colors={['var(--border-norm)', 'var(--border-weak)']} /> <hr /> <ColorItem title="Signal Danger" subtitle="" colors={[ 'var(--signal-danger-minor-2)', 'var(--signal-danger-minor-1)', 'var(--signal-danger)', 'var(--signal-danger-major-1)', 'var(--signal-danger-major-2)', 'var(--signal-danger-major-3)', 'var(--signal-danger-contrast)', ]} /> <ColorItem title="Signal Warning" subtitle="" colors={[ 'var(--signal-warning-minor-2)', 'var(--signal-warning-minor-1)', 'var(--signal-warning)', 'var(--signal-warning-major-1)', 'var(--signal-warning-major-2)', 'var(--signal-warning-major-3)', 'var(--signal-warning-contrast)', ]} /> <ColorItem title="Signal Success" subtitle="" colors={[ 'var(--signal-success-minor-2)', 'var(--signal-success-minor-1)', 'var(--signal-success)', 'var(--signal-success-major-1)', 'var(--signal-success-major-2)', 'var(--signal-success-major-3)', 'var(--signal-success-contrast)', ]} /> <ColorItem title="Signal Info" subtitle="" colors={[ 'var(--signal-info-minor-2)', 'var(--signal-info-minor-1)', 'var(--signal-info)', 'var(--signal-info-major-1)', 'var(--signal-info-major-2)', 'var(--signal-info-major-3)', 'var(--signal-info-contrast)', ]} /> <hr /> <ColorItem title="Interaction Default" subtitle="" colors={[ 'var(--interaction-default)', 'var(--interaction-default-hover)', 'var(--interaction-default-active)', ]} /> <ColorItem title="Interaction Norm" subtitle="" colors={[ 'var(--interaction-norm-minor-2)', 'var(--interaction-norm-minor-1)', 'var(--interaction-norm)', 'var(--interaction-norm-major-1)', 'var(--interaction-norm-major-2)', 'var(--interaction-norm-major-3)', 'var(--interaction-norm-contrast)', ]} /> <ColorItem title="Interaction Weak" subtitle="" colors={[ 'var(--interaction-weak-minor-2)', 'var(--interaction-weak-minor-1)', 'var(--interaction-weak)', 'var(--interaction-weak-major-1)', 'var(--interaction-weak-major-2)', 'var(--interaction-weak-major-3)', 'var(--interaction-weak-contrast)', ]} /> </ColorPalette> </> ); export const BaseStandard = () => ( <> <div className="ui-standard border rounded p-4"> <BaseColors /> </div> </> ); export const BaseProminent = () => ( <> <div className="ui-prominent rounded p-4"> <BaseColors /> </div> </> );
4,593
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/coreConcepts/Icons.mdx
import { Canvas, Primary, Story } from '@storybook/addon-docs'; # Icon set Here is the custom icon set for Proton applications. To use an icon in your code, refer to the [Icon component](/docs/components-icon--basic). <Story id="core-concepts-icons--icons" /> <div class="hidden"> <Primary /> </div>
4,594
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/coreConcepts/Icons.stories.tsx
import { useMemo, useState } from 'react'; import { Button, Input } from '@proton/atoms'; import { ButtonGroup, Icon, IconName, Mark } from '@proton/components'; import iconSvg from '@proton/styles/assets/img/icons/sprite-icons.svg'; import { getTitle } from '../../helpers/title'; import mdx from './Icons.mdx'; export default { title: getTitle(__filename, false), parameters: { docs: { page: mdx, }, }, }; type IconProps = React.ComponentProps<typeof Icon>; const sizes: Required<IconProps>['size'][] = [16, 20, 28, 40, 60]; export const Icons = () => { const [selectedSize, setSelectedSize] = useState<Required<IconProps>['size']>(40); const primaryIconNames: IconName[] = iconSvg.match(/id="ic-([^"]+)/g).map((x: string) => x.replace('id="ic-', '')); const [search, setSearch] = useState(''); const iconResults = useMemo(() => { if (search.length <= 1) { return primaryIconNames; } return primaryIconNames.filter((x) => x.toLowerCase().includes(search.toLocaleLowerCase())); }, [search]); return ( <> <div className="flex flex-nowrap gap-4"> <Input prefix={<Icon name="magnifier" />} placeholder={`Search ${primaryIconNames.length} icons by name…`} value={search} onChange={({ target: { value } }) => setSearch(value)} className="flex-item-fluid" /> <ButtonGroup> {sizes.map((size) => ( <Button onClick={() => setSelectedSize(size)} selected={size === selectedSize} title={`Set icon size to ${size}`} > {size} </Button> ))} </ButtonGroup> </div> <div className="icon-grid mt-8"> {iconResults.map((iconName) => ( <div className="border rounded text-center p-4" key={iconName}> <Icon name={iconName} size={selectedSize} /> <div className="mt-4 text-monospace lh120 user-select"> <Mark value={search}>{iconName}</Mark> </div> </div> ))} </div> </> ); };
4,595
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/coreConcepts/LayersManagement.stories.mdx
import { Meta, Source } from '@storybook/addon-docs'; import { getTitle } from '../../helpers/title'; <Meta title={getTitle(__filename)} /> # Layers management (z-indexes) ## TLDR We have create some SASS variables for managing layer stack. ## Variable list Here are the available variables. Remember that you don't really need to take care of their value for **abstraction purposes**, so let's consider them as from higher to lower level layer. - **`$layer-tooltips`** for tooltips - **`$layer-notifications`** for notifications - **`$layer-modals`** for modals and dropdowns - **`$layer-mobile-navigation`** for navigation bar on mobile - **`$layer-previewer`** for file preview - **`$layer-floating-frames`** for floating frames, sush as the composer or transfer manager - **`$layer-floating-action-buttons`** for floating action buttons, sush as new message on mobile - **`$layer-dropzone`** for drag and drop zone area ## Example <Source language="css" format copy={false} code={` @import '~@proton/styles/scss/lib';   .transfers-manager { position: fixed; z-index: $layer-floating-frames; /* … */ } `} /> ## Special treatment There's a helper that can be used to make sure that a component is over other ones: **`.upper-layer`**, which is using **`$layer-upper`** variable. This variable has a lower value than any other layer variable. ## Why? Managing z-indexes of a growing number of components can quickly become tricky: which one should be on top or below of another? At what index does it belong? Does it make sense that it's on the same level as another? To simplify this process, we create an **abstraction with variables** intended to find more easily where a component belongs to. ## Statements First of all, let's imagine the z-indexes as **layers**. It's easier to work with and more understandable. Then, let's remind ourselves that components placed **at the same layer** are **stacked in an increasing order**. That means that the last component in the DOM tree will be on top of other components at the same layer. Let's remind ourselves also that the `z-index` property **needs to be used in addition to the `position` property**. By doing so, you will create a new **[stacking context](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context)**, so all the `z-index` applied on any children would be scoped inside that stacking context, and won't have any effect on the outside. Oh, and you can create stacking contexts inside stacking contexts, but good luck with that! Since those variables don't need to be changed at any time in client side, we chose to use SASS variables instead of CSS variables. And finally, to give some flexibility, **the first hundred of indexes are free for any specific purpose**. The lowest layer is defined at `100`, the other ones are defined at an incremental step of one hundred. That leaves room for any specificity between those values in a specific layer.
4,596
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/coreConcepts/Responsive.stories.mdx
import { Meta, Source } from '@storybook/addon-docs'; import { Alert } from '@proton/components'; import { getTitle } from '../../helpers/title'; <Meta title={getTitle(__filename)} /> # Responsive and media queries In order to be able to write CSS/SCSS media queries in an easy and maintainable way with a natural and simplistic syntax, we are using the [include-media library](https://eduardoboucas.github.io/include-media/). ## Basics The library comes with a list of default breakpoints that we changed for our needs: <Source language="css" format copy={false} code={` /* Variable set in the design system's config. You don't have to create another one. */ $breakpoints: im-to-em(( 'xlarge': 1500px, 'large' : 1100px, 'medium': 910px, 'small' : 680px, 'xsmall': 450px, ));   /* Inclusive and exclusive operators for a finer control over the intervals */ @include media(">small", "<=medium") { width: 50%; }   /* Use ligatured operators if you fancy a slicker declaration */ @include media(">small", "≤medium") { line-height: 1.5; } `} /> Those value are already overrided for some apps, Mail and Calendar as I'm writing this line. `$breakpoints` is a map variable specific to include-media. `im-to-em`, standing for _include media to em unit_, is a specific helper for converting pixel values into em values. This way, these values are kept as reachable as possible. Due to the wide variety of devices, and their diversity in size, we no longer mention any device in the naming. From now on, it will be graduated sizes from `xsmall` to `xlarge`, leaving us the possibility to extend the list as needed. <Alert type="warning"> As a recommandation, please always use inclusive value for max witdh ( <b> <code>&lt;=</code> </b> ) and exclusive value for min width (<b> <code>&gt;</code> </b> ). </Alert> ## On-the-fly breakpoints Some elements require additional rules on intermediate breakpoints, so you can create media queries that use both global breakpoints and case-specific values. <Alert type="warning">Always make sure that you need a specific breakpoint. Challenge the design if necessary.</Alert> <Source language="css" format copy={false} code={` @include media('<=#{em(640, 16)}') { display: none; } `} /> Here, we need to convert the pixel value `640` into an em value, so we are using the `em` function with the `16` base font size, which is the browser default. <Alert type="warning"> Always convert media query pixel breakpoints into <code>em</code>… or use an <code>em</code> value directly. This makes the breapoint browser zooming compatible. </Alert> ## Smart support for media types Media types and static expressions are optional and automatically deferred. The list of media types is declared by `$media-expressions`. <Source language="css" format copy={false} code={` /* Variable set in the design system's config. You don't have to create another one. */ $media-expressions: ( 'screen': 'screen', 'print': 'print', 'mouse': '(hover: hover) and (pointer: fine)', 'touch': '(hover: hover) and (pointer: coarse), (hover: none)', 'landscape': '(orientation: landscape)', 'portrait': '(orientation: portrait)', 'reduced-motion': '(prefers-reduced-motion: reduce)', );   @include media('mouse', '>small') { display: inline-flex; } `} /> ## Height-based media queries All expressions result in a `min-width` or `max-width` expression by default, but you can explicitly use any breakpoint with `min-height` and `max-height` instead. <Source language="css" format copy={false} code={` @include media('height>small', 'height<=#{em(600, 16)}') { height: 50%; } `} /> ## Other Features For further features, check the [include-media full documentation](https://eduardoboucas.github.io/include-media/documentation/).
4,597
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/coreConcepts/SassCssVariables.stories.mdx
import { Meta } from '@storybook/addon-docs'; import { getTitle } from '../../helpers/title'; <Meta title={getTitle(__filename)} /> # Sass and CSS variables ## General rules for Sass variables - If possible, create Sass variables, once a property or a value is often used in a module or if the information inside is useful for several modules. - “Global/local” variable: if your variable is aimed to be used only in the partial (only related to something in your partial and nothing else), leave it in the partial. <br /> Otherwise, please put it in <code>design-system-config</code>, in order to make people understand that it can be used in several cases. - And if possible, do open an issue on Design System to document it. :) ### List of all most important Sass variables #### Global layout - <code>$header-height</code>: height of top header - <code>$width-sidebar</code>: width of the left sidebar - <code>$toolbar-height</code>: height of the grey toolbar - <code>$conversations-column-width</code>: used for conversations column width (!), and to align searchbox container - <code>$pm-primary</code>: alias for main color on the project (by default to <code>$pm-blue</code>) - <code>$pm-primary-light</code>: alias for main light color on the project (by default to <code>$pm-blue-light</code>) - <code>$pm-primary-dark</code>: alias for main dark color on the project (by default to <code>$pm-blue-dark</code>) For color variables, have a look at <a href="/colors/">colors section</a>. ### Overwriting variables If you need (for your project) to set up different values than the default one of the design system, do overwrite variables in <code>styles-pm.scss</code>, <strong class="text-uppercase">not</strong> in Sass partials, as they could be updated later. Each variable in Sass partials <strong class="text-uppercase">must</strong> have <code>!default</code>, in order to avoid break layout on each project with different settings. ## CSS variables (custom properties) These CSS custom properties are present to allow easy theming of the interface. ### Global ones #### Colors - <code>--main-bg-color</code>: global main color - <code>--secondary-bg-color</code>: secondary main color - <code>--bgcolor-searchbox-field</code>: background-color of searchbox - <code>--boxshadow-main</code>: used to apply a box shadow on main content (used for light theme for example) - <code>--bgcolor-main-area</code>: background-color of the main area (settings) - <code>--color-main-area</code>: color of the main area (settings) - <code>--bgcolor-toolbar</code>: background-color of the toolbar - <code>--color-nav-link</code>: color used for navigation links - <code>--color-nav-active</code>: color used for navigation links when active - <code>--color-standard-text</code>: color used for text - <code>--fillcolor-logo</code>: color used for filling SVG logo - <code>--fillcolor-icons</code>: color used for filling icons #### Inputs - <code>--bordercolor-input</code>: border-color of the inputs - <code>--bgcolor-input</code>: background-color of the inputs - <code>--color-input</code>: color of the text in inputs #### List mails/contacts - <code>--bgcolor-item-column-list</code>: background-color of the list of items/mails (left column in conversations) - <code>--bgcolor-unread-item-column-list</code>: background-color of unread items/mails (left column in conversations) - <code>--bgcolor-item-column-active</code>: background-color of the list of items/mails (left column in conversations) - <code>--bgcolor-view-column-detail</code>: background-color of the detail view of emails (right column in conversations) #### UI widths/sizes - <code>--width-sidebar</code>: width of the navigation - <code>--width-conversation-column</code>: width of the conversation column - <code>--width-subnav</code>: width of the sub navigation (short links) - <code>--body-fontsize</code>: global font size. - <code>--label-width</code>: the width of <code>label</code> (in forms) #### Spacings - <code>--space-0</code>: 0 - <code>--space-0-5</code>: 0.125rem - <code>--space-1</code>: 0.25rem - <code>--space-2</code>: 0.5rem - <code>--space-3</code>: 0.75rem - <code>--space-4</code>: 1rem - <code>--space-5</code>: 1.25rem - <code>--space-6</code>: 1.5rem - <code>--space-7</code>: 1.75rem - <code>--space-8</code>: 2rem - <code>--space-10</code>: 2.5rem - <code>--space-11</code>: 2.75rem - <code>--space-12</code>: 3rem - <code>--space-14</code>: 3.5rem - <code>--space-auto</code>: auto #### Other specific components - <code>--bgcolor-highlight</code>: background-color of highlight helper - <code>--bgcolor-muted</code>: background-color of muted color - <code>--bgcolor-meter-bar</code>: the background color of <code>meter</code> - <code>--bgcolor-mark</code>: the background color of <code>mark</code> - <code>--color-mark</code>: the color of <code>mark</code> - <code>--bgcolor-calendar-now-indicator</code>: background-color for now hour line indicator #### To triage - <code>--bgcolor-spacebar</code>: background-color of remaining space bar - <code>--bgcolor-aside-link</code>: background-color of link icons in aside bar. Updating these custom properties allows to create simple themes without surcharging all the CSS stuff. If you need to check where they are used, perform a search of have a look at <code>design-system-website/\_themes.scss</code>, it contains all rules that are using them. This partial should <strong class="text-uppercase">not</strong> be used in production, it is only for testing and reference purposes.
4,598
0
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories
petrpan-code/ProtonMail/WebClients/applications/storybook/src/stories/coreConcepts/Typography.mdx
import { Canvas, Primary, Story } from '@storybook/addon-docs'; # Typography ## Normal text Proton apps suite uses **Inter** as the default typeface in all current themes. Inter is available in three font weights: <Story id="core-concepts-typography--font" /> ### Headings Typographic scale for headings <Story id="core-concepts-typography--headings" /> ### Text Typographic scale for regular text <Story id="core-concepts-typography--text" /> ### Colors Available colors to use with text <Story id="core-concepts-typography--colors" /> ## Monospace For any source code, Proton apps suite uses a monospaced system font stack. <Story id="core-concepts-typography--monospace" /> ```css .text-monospace, pre, code, kbd, samp { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace; } ``` <div class="hidden"> <Primary /> </div>
4,599