@brightspot/ui 1.0.0-alpha.1 → 1.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/dist/LucideDynamicLoader.js +21 -0
  2. package/dist/LucideDynamicLoader.ts +23 -0
  3. package/dist/storybook/342.9186a774.iframe.bundle.js +2 -0
  4. package/dist/storybook/342.9186a774.iframe.bundle.js.LICENSE.txt +6 -0
  5. package/dist/storybook/{906.c7ad56cf.iframe.bundle.js → 906.72b6fffa.iframe.bundle.js} +4 -4
  6. package/dist/storybook/{906.c7ad56cf.iframe.bundle.js.map → 906.72b6fffa.iframe.bundle.js.map} +1 -1
  7. package/dist/storybook/iframe.html +3 -3
  8. package/dist/storybook/index.json +1 -1
  9. package/dist/storybook/main.8dadaa0a.iframe.bundle.js +1 -0
  10. package/dist/storybook/project.json +1 -1
  11. package/dist/storybook/runtime~main.36ab40ff.iframe.bundle.js +1 -0
  12. package/dist/storybook/{stories-Button-stories.5286bed3.iframe.bundle.js → stories-Button-stories.777d0529.iframe.bundle.js} +2 -2
  13. package/dist/storybook/stories-Button-stories.777d0529.iframe.bundle.js.map +1 -0
  14. package/dist/storybook/stories-Icon-stories.171bf8c3.iframe.bundle.js +8 -0
  15. package/dist/storybook/stories-Icon-stories.171bf8c3.iframe.bundle.js.map +1 -0
  16. package/dist/tailwind-plugin-icon.js +4 -133
  17. package/dist/tailwind-plugin-icon.ts +4 -147
  18. package/dist/util/string.js +14 -0
  19. package/dist/util/svg.js +13 -0
  20. package/package.json +1 -1
  21. package/dist/storybook/main.7b0cb99d.iframe.bundle.js +0 -1
  22. package/dist/storybook/runtime~main.4a7b6ddf.iframe.bundle.js +0 -1
  23. package/dist/storybook/stories-Button-stories.5286bed3.iframe.bundle.js.map +0 -1
  24. /package/dist/storybook/{906.c7ad56cf.iframe.bundle.js.LICENSE.txt → 906.72b6fffa.iframe.bundle.js.LICENSE.txt} +0 -0
@@ -1 +1 @@
1
- {"generatedAt":1749563080275,"hasCustomBabel":false,"hasCustomWebpack":false,"hasStaticDirs":false,"hasStorybookEslint":true,"refCount":0,"testPackages":{},"hasRouterPackage":false,"packageManager":{"type":"yarn","agent":"yarn"},"preview":{"usesGlobals":false},"framework":{"name":"@storybook/web-components-webpack5","options":{"builder":{"useSWC":true}}},"builder":"@storybook/builder-webpack5","renderer":"@storybook/web-components","portableStoriesFileCount":0,"applicationFileCount":0,"storybookVersion":"8.6.12","storybookVersionSpecifier":"^8.6.12","language":"typescript","storybookPackages":{"@storybook/blocks":{"version":"8.6.12"},"@storybook/test":{"version":"8.6.12"},"@storybook/web-components":{"version":"8.6.12"},"@storybook/web-components-webpack5":{"version":"8.6.12"},"eslint-plugin-storybook":{"version":"0.12.0"},"storybook":{"version":"8.6.12"}},"addons":{"@storybook/addon-webpack5-compiler-swc":{"version":"3.0.0"},"@storybook/addon-essentials":{"version":"8.6.12"},"@storybook/addon-styling-webpack":{"version":"1.0.1"}}}
1
+ {"generatedAt":1749834711051,"hasCustomBabel":false,"hasCustomWebpack":false,"hasStaticDirs":false,"hasStorybookEslint":true,"refCount":0,"testPackages":{},"hasRouterPackage":false,"packageManager":{"type":"yarn","agent":"yarn"},"preview":{"usesGlobals":false},"framework":{"name":"@storybook/web-components-webpack5","options":{"builder":{"useSWC":true}}},"builder":"@storybook/builder-webpack5","renderer":"@storybook/web-components","portableStoriesFileCount":0,"applicationFileCount":0,"storybookVersion":"8.6.12","storybookVersionSpecifier":"^8.6.12","language":"typescript","storybookPackages":{"@storybook/blocks":{"version":"8.6.12"},"@storybook/test":{"version":"8.6.12"},"@storybook/web-components":{"version":"8.6.12"},"@storybook/web-components-webpack5":{"version":"8.6.12"},"eslint-plugin-storybook":{"version":"0.12.0"},"storybook":{"version":"8.6.12"}},"addons":{"@storybook/addon-webpack5-compiler-swc":{"version":"3.0.0"},"@storybook/addon-essentials":{"version":"8.6.12"},"@storybook/addon-styling-webpack":{"version":"1.0.1"}}}
@@ -0,0 +1 @@
1
+ (()=>{"use strict";var deferred,inProgress,__webpack_modules__={},__webpack_module_cache__={};function __webpack_require__(moduleId){var cachedModule=__webpack_module_cache__[moduleId];if(void 0!==cachedModule)return cachedModule.exports;var module=__webpack_module_cache__[moduleId]={id:moduleId,exports:{}};return __webpack_modules__[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.exports}__webpack_require__.m=__webpack_modules__,__webpack_require__.amdO={},deferred=[],__webpack_require__.O=(result,chunkIds,fn,priority)=>{if(!chunkIds){var notFulfilled=1/0;for(i=0;i<deferred.length;i++){for(var[chunkIds,fn,priority]=deferred[i],fulfilled=!0,j=0;j<chunkIds.length;j++)(!1&priority||notFulfilled>=priority)&&Object.keys(__webpack_require__.O).every((key=>__webpack_require__.O[key](chunkIds[j])))?chunkIds.splice(j--,1):(fulfilled=!1,priority<notFulfilled&&(notFulfilled=priority));if(fulfilled){deferred.splice(i--,1);var r=fn();void 0!==r&&(result=r)}}return result}priority=priority||0;for(var i=deferred.length;i>0&&deferred[i-1][2]>priority;i--)deferred[i]=deferred[i-1];deferred[i]=[chunkIds,fn,priority]},__webpack_require__.n=module=>{var getter=module&&module.__esModule?()=>module.default:()=>module;return __webpack_require__.d(getter,{a:getter}),getter},__webpack_require__.d=(exports,definition)=>{for(var key in definition)__webpack_require__.o(definition,key)&&!__webpack_require__.o(exports,key)&&Object.defineProperty(exports,key,{enumerable:!0,get:definition[key]})},__webpack_require__.f={},__webpack_require__.e=chunkId=>Promise.all(Object.keys(__webpack_require__.f).reduce(((promises,key)=>(__webpack_require__.f[key](chunkId,promises),promises)),[])),__webpack_require__.u=chunkId=>(({123:"stories-Heading-stories",264:"stories-ScrollShadow-stories",471:"stories-Colors-stories",544:"stories-Badge-stories",791:"stories-Button-stories",840:"stories-Icon-stories",894:"stories-Loader-stories"}[chunkId]||chunkId)+"."+{123:"b41961f8",264:"252ec9e7",342:"9186a774",364:"84b2a293",471:"324d20d0",544:"52b61cf3",648:"0f0c2ea1",689:"b6901a43",791:"777d0529",840:"171bf8c3",894:"cd5e8fb5",936:"7e4d4897",980:"2bfde12a"}[chunkId]+".iframe.bundle.js"),__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),__webpack_require__.o=(obj,prop)=>Object.prototype.hasOwnProperty.call(obj,prop),inProgress={},__webpack_require__.l=(url,done,key,chunkId)=>{if(inProgress[url])inProgress[url].push(done);else{var script,needAttach;if(void 0!==key)for(var scripts=document.getElementsByTagName("script"),i=0;i<scripts.length;i++){var s=scripts[i];if(s.getAttribute("src")==url||s.getAttribute("data-webpack")=="@brightspot/ui:"+key){script=s;break}}script||(needAttach=!0,(script=document.createElement("script")).charset="utf-8",script.timeout=120,__webpack_require__.nc&&script.setAttribute("nonce",__webpack_require__.nc),script.setAttribute("data-webpack","@brightspot/ui:"+key),script.src=url),inProgress[url]=[done];var onScriptComplete=(prev,event)=>{script.onerror=script.onload=null,clearTimeout(timeout);var doneFns=inProgress[url];if(delete inProgress[url],script.parentNode&&script.parentNode.removeChild(script),doneFns&&doneFns.forEach((fn=>fn(event))),prev)return prev(event)},timeout=setTimeout(onScriptComplete.bind(null,void 0,{type:"timeout",target:script}),12e4);script.onerror=onScriptComplete.bind(null,script.onerror),script.onload=onScriptComplete.bind(null,script.onload),needAttach&&document.head.appendChild(script)}},__webpack_require__.r=exports=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(exports,"__esModule",{value:!0})},__webpack_require__.p="",(()=>{__webpack_require__.b=document.baseURI||self.location.href;var installedChunks={354:0};__webpack_require__.f.j=(chunkId,promises)=>{var installedChunkData=__webpack_require__.o(installedChunks,chunkId)?installedChunks[chunkId]:void 0;if(0!==installedChunkData)if(installedChunkData)promises.push(installedChunkData[2]);else if(354!=chunkId){var promise=new Promise(((resolve,reject)=>installedChunkData=installedChunks[chunkId]=[resolve,reject]));promises.push(installedChunkData[2]=promise);var url=__webpack_require__.p+__webpack_require__.u(chunkId),error=new Error;__webpack_require__.l(url,(event=>{if(__webpack_require__.o(installedChunks,chunkId)&&(0!==(installedChunkData=installedChunks[chunkId])&&(installedChunks[chunkId]=void 0),installedChunkData)){var errorType=event&&("load"===event.type?"missing":event.type),realSrc=event&&event.target&&event.target.src;error.message="Loading chunk "+chunkId+" failed.\n("+errorType+": "+realSrc+")",error.name="ChunkLoadError",error.type=errorType,error.request=realSrc,installedChunkData[1](error)}}),"chunk-"+chunkId,chunkId)}else installedChunks[chunkId]=0},__webpack_require__.O.j=chunkId=>0===installedChunks[chunkId];var webpackJsonpCallback=(parentChunkLoadingFunction,data)=>{var moduleId,chunkId,[chunkIds,moreModules,runtime]=data,i=0;if(chunkIds.some((id=>0!==installedChunks[id]))){for(moduleId in moreModules)__webpack_require__.o(moreModules,moduleId)&&(__webpack_require__.m[moduleId]=moreModules[moduleId]);if(runtime)var result=runtime(__webpack_require__)}for(parentChunkLoadingFunction&&parentChunkLoadingFunction(data);i<chunkIds.length;i++)chunkId=chunkIds[i],__webpack_require__.o(installedChunks,chunkId)&&installedChunks[chunkId]&&installedChunks[chunkId][0](),installedChunks[chunkId]=0;return __webpack_require__.O(result)},chunkLoadingGlobal=self.webpackChunk_brightspot_ui=self.webpackChunk_brightspot_ui||[];chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null,0)),chunkLoadingGlobal.push=webpackJsonpCallback.bind(null,chunkLoadingGlobal.push.bind(chunkLoadingGlobal))})(),__webpack_require__.nc=void 0})();
@@ -5,5 +5,5 @@
5
5
  >
6
6
  ${label}
7
7
  </button>
8
- `})(args),argTypes:{size:{control:{type:"select"},options:["sm","md","lg","xl","2xl"]},color:{control:{type:"select"},options:["primary","gray","error"]},pressed:{control:{type:"boolean"},description:"Is the button pressed?"},fill:{control:{type:"boolean"},description:"Is the button filled?"},contained:{control:{type:"boolean"},description:"Does the button have a container?"},outlined:{control:{type:"boolean"},description:"Is the button outlined?"}},args:{color:"primary",label:"Button",pressed:!1,fill:!0,contained:!0,outlined:!1,size:"md"}},Default={args:{}},__namedExportsOrder=["Default"];Default.parameters={...Default.parameters,docs:{...Default.parameters?.docs,source:{originalSource:"{\n args: {}\n}",...Default.parameters?.docs?.source}}}}}]);
9
- //# sourceMappingURL=stories-Button-stories.5286bed3.iframe.bundle.js.map
8
+ `})(args),argTypes:{size:{control:{type:"select"},options:["sm","md","lg","xl","2xl"]},color:{control:{type:"select"},options:["black","white","primary","teal","gray","purple","rose","error","warning","success"]},pressed:{control:{type:"boolean"},description:"Is the button pressed?"},fill:{control:{type:"boolean"},description:"Is the button filled?"},contained:{control:{type:"boolean"},description:"Does the button have a container?"},outlined:{control:{type:"boolean"},description:"Is the button outlined?"}},args:{color:"primary",label:"Button",pressed:!1,fill:!0,contained:!0,outlined:!1,size:"md"}},Default={args:{}},__namedExportsOrder=["Default"];Default.parameters={...Default.parameters,docs:{...Default.parameters?.docs,source:{originalSource:"{\n args: {}\n}",...Default.parameters?.docs?.source}}}}}]);
9
+ //# sourceMappingURL=stories-Button-stories.777d0529.iframe.bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stories-Button-stories.777d0529.iframe.bundle.js","mappings":";;;AAmCA;;AAUA;;AAEA","sources":["webpack://@brightspot/ui/./src/stories/Button.ts"],"sourcesContent":["import { html } from 'lit'\nimport type { ThemeColors } from '../tailwind-plugin-theme'\n\nexport interface ButtonProps {\n color?: ThemeColors\n /** Is the button depressed or not? */\n pressed?: boolean\n /** Should the button have a background? */\n fill?: boolean\n /** Should the button have a container? */\n contained?: boolean\n /** Should the button be outlined? */\n outlined?: boolean\n /** How large should the button be? */\n size?: 'sm' | 'md' | 'lg' | 'xl' | '2xl'\n label: string\n}\n\nexport const Button = ({\n color = 'primary',\n pressed,\n fill,\n contained,\n outlined,\n size = 'sm',\n label,\n}: ButtonProps) => {\n const depressed = pressed ? 'btu-button-pressed' : ''\n const filled = fill ? 'btu-button-fill' : 'btu-button-fill-none'\n const container = contained ? '' : 'btu-button-container-none'\n const outline = outlined ? 'btu-button-outline' : ''\n\n return html`\n <button\n type=\"button\"\n class=${[\n 'btu-button',\n `btu-button-${color}`,\n `btu-button-${size}`,\n filled,\n container,\n outline,\n depressed,\n ].join(' ')}\n >\n ${label}\n </button>\n `\n}\n"],"names":[],"sourceRoot":""}
@@ -0,0 +1,8 @@
1
+ "use strict";(self.webpackChunk_brightspot_ui=self.webpackChunk_brightspot_ui||[]).push([[840],{"./src/stories/Icon.stories.ts":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{Default:()=>Default,__namedExportsOrder:()=>__namedExportsOrder,default:()=>Icon_stories});var lit=__webpack_require__("./node_modules/lit/index.js"),info=__webpack_require__("./node_modules/lucide-static/font/info.json"),lucide_static=__webpack_require__("./node_modules/lucide-static/dist/esm/lucide-static.js");const symbols=/[\r\n%#()<>?[\\\]^`{|}]/g;function getIcon(iconName){try{const kebabName=iconName.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),pascalName=function kebabToPascal(str){return str.split("-").map((word=>word.charAt(0).toUpperCase()+word.slice(1))).join("")}(kebabName);if(lucide_static[pascalName]){const encodedSvg=function encodeSVG(data){return(data=(data=(data=data.replace(/"/g,"'")).replace(/>\s{1,}</g,"><")).replace(/\s{2,}/g," ")).replace(symbols,encodeURIComponent)}(function addNameSpaceXML(data){return data.indexOf("http://www.w3.org/2000/svg")<0&&(data=data.replace(/<svg/g,"<svg xmlns='http://www.w3.org/2000/svg'")),data}(lucide_static[pascalName]));return{compat:info[kebabName]?.encodedCode||"",iconSvg:encodedSvg}}}catch(e){console.error("Error loading Lucide icon ${iconName}:",e)}}const Icon_stories={title:"Components/Icon",component:"btu-icon",tags:["autodocs"],parameters:{docs:{subtitle:"We use Lucide Icons: https://lucide.dev/icons/. All strokes in these icons have been converted to single vectors so color overrides are respected within variants. We recommend attaching icon classes to before/after pseudo-elements, like so: `before:btu-icon before:btu-icon-smile`."},controls:{expanded:!0}},render:args=>(({name,size="md"})=>{let data,kebabName,icon="";return name?(data=getIcon(name),kebabName=name.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()):icon="before:btu-icon-smile",lit.qy`
2
+ <div
3
+ style=${`--compat-icon:'${info[kebabName]?.encodedCode||""}';\n --Icon-svg: url("data:image/svg+xml,${data?.iconSvg||""}");\n --compat-icon-via-mask: url("data:image/svg+xml,${data?.iconSvg}");`}
4
+ data-icon=${name?`${name}`:""}
5
+ class=${["before:btu-icon",`before:btu-icon-${size}`,icon].join(" ")}
6
+ ></div>
7
+ `})(args),argTypes:{size:{control:{type:"select"},description:"Icon size. Works with arbitrary values like: `before:btu-icon-[10.5rem]`",options:["xs","sm","md","lg","xl"]},name:{control:{type:"text"},description:"Name of the icon to display. Try names like `waves`, `salad`, or `star`."}},args:{size:"xl"}},Default={args:{}},__namedExportsOrder=["Default"];Default.parameters={...Default.parameters,docs:{...Default.parameters?.docs,source:{originalSource:"{\n args: {}\n}",...Default.parameters?.docs?.source}}}}}]);
8
+ //# sourceMappingURL=stories-Icon-stories.171bf8c3.iframe.bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stories-Icon-stories.171bf8c3.iframe.bundle.js","mappings":";;AA6BA;AAGA;AACA;;AAEA","sources":["webpack://@brightspot/ui/./src/stories/Icon.ts"],"sourcesContent":["import { html } from 'lit'\nimport icons from 'lucide-static/font/info.json'\nimport { getIcon } from '../LucideDynamicLoader'\n\nexport interface IconProps {\n name?: string\n /** How large should the icon be?\n before:btu-icon-xs\n before:btu-icon-sm\n before:btu-icon-md\n before:btu-icon-lg\n before:btu-icon-xl\n */\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n}\n\nexport const Icon = ({ name, size = 'md' }: IconProps) => {\n let data\n let kebabName\n let icon = ''\n if (!name) {\n icon = 'before:btu-icon-smile'\n } else {\n data = getIcon(name)\n kebabName = name.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()\n }\n\n return html`\n <div\n style=${`--compat-icon:'${icons[kebabName as keyof typeof icons]?.encodedCode || ''}';\n --Icon-svg: url(\"data:image/svg+xml,${data?.iconSvg || ''}\");\n --compat-icon-via-mask: url(\"data:image/svg+xml,${data?.iconSvg}\");`}\n data-icon=${name ? `${name}` : ''}\n class=${['before:btu-icon', `before:btu-icon-${size}`, icon].join(' ')}\n ></div>\n `\n}\n"],"names":[],"sourceRoot":""}
@@ -1,6 +1,8 @@
1
1
  import plugin from 'tailwindcss/plugin';
2
2
  import icons from 'lucide-static/font/info.json';
3
3
  import * as LucideExports from 'lucide-static/dist/cjs/lucide-static';
4
+ import { pascalToKebab } from './util/string';
5
+ import { addNameSpaceXML, encodeSVG } from './util/svg';
4
6
  /**
5
7
  * Lucide Icons | https://lucide.dev/icons/
6
8
  * Each icon is designed on a 24x24 grid with an emphasis on simplicity, consistency and readability.
@@ -39,31 +41,7 @@ for (const [key, value] of Object.entries(LucideExports)) {
39
41
  }
40
42
  }
41
43
  }
42
- function addNameSpace(data) {
43
- if (data.indexOf(`http://www.w3.org/2000/svg`) < 0) {
44
- data = data.replace(/<svg/g, `<svg xmlns='http://www.w3.org/2000/svg'`);
45
- }
46
- return data;
47
- }
48
- function pascalToKebab(str) {
49
- return str
50
- .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
51
- .replace(/([A-Za-z])([0-9])/g, '$1-$2')
52
- .toLowerCase();
53
- }
54
- function kebabToPascal(str) {
55
- return str
56
- .split('-')
57
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
58
- .join('');
59
- }
60
- function encodeSVG(data) {
61
- data = data.replace(/"/g, `'`);
62
- data = data.replace(/>\s{1,}</g, `><`);
63
- data = data.replace(/\s{2,}/g, ` `);
64
- return data.replace(symbols, encodeURIComponent);
65
- }
66
- module.exports = plugin(function ({ addBase, addComponents, matchUtilities, theme }) {
44
+ module.exports = plugin(function ({ addComponents, matchUtilities, theme }) {
67
45
  const size = 'var(--Icon-size)';
68
46
  const prefix = '.btu-icon-';
69
47
  Object.entries(svgs).forEach(([key, svg]) => {
@@ -76,7 +54,7 @@ module.exports = plugin(function ({ addBase, addComponents, matchUtilities, them
76
54
  },
77
55
  [`${prefix}via-mask-${pascalToKebab(key)}`]: {
78
56
  '--size': '20px',
79
- '--Icon-svg': `url("data:image/svg+xml,${encodeSVG(addNameSpace(svg))}")`,
57
+ '--Icon-svg': `url("data:image/svg+xml,${encodeSVG(addNameSpaceXML(svg))}")`,
80
58
  mask: 'var(--Icon-svg) center / contain no-repeat',
81
59
  'aspect-ratio': '1',
82
60
  'inline-size': 'var(--Icon-size, --size)',
@@ -126,113 +104,6 @@ module.exports = plugin(function ({ addBase, addComponents, matchUtilities, them
126
104
  '--Icon-size': value,
127
105
  }),
128
106
  }, { values: theme('iconSize') });
129
- // Compat v4 Icons:
130
- // Icon names which are Google Material icons mapped to a lucide equivalent to support the legacy markup.
131
- const compatNames = new Map();
132
- compatNames.set('arrow_downward', 'arrow-down');
133
- compatNames.set('arrow_upward', 'arrow-up');
134
- compatNames.set('assessment', 'file-chart-pie');
135
- compatNames.set('assignment', 'clipboard-check');
136
- compatNames.set('attachment', 'file');
137
- compatNames.set('auto_stories', 'book');
138
- compatNames.set('ballot', 'shield-question');
139
- compatNames.set('border_all', 'table-2');
140
- compatNames.set('cancel', 'circle-x');
141
- compatNames.set('chat_bubble', 'message-circle');
142
- compatNames.set('check_circle', 'circle-check-big');
143
- compatNames.set('chrome_reader_mode', 'table-properties');
144
- compatNames.set('class', 'book-type');
145
- compatNames.set('close', 'x');
146
- compatNames.set('code', 'code');
147
- compatNames.set('comment', 'message-circle-plus');
148
- compatNames.set('comments_disabled', 'message-circle-x');
149
- compatNames.set('create_new_folder', 'boxes');
150
- compatNames.set('description', 'file-text');
151
- compatNames.set('edit', 'pencil');
152
- compatNames.set('error', 'circle-alert');
153
- compatNames.set('expand_more', 'chevrons-up-down');
154
- compatNames.set('expand_less', 'chevrons-down-up');
155
- compatNames.set('feed', 'scroll-text');
156
- compatNames.set('format_align_center', 'align-center');
157
- compatNames.set('format_align_left', 'align-left');
158
- compatNames.set('format_align_right', 'align-right');
159
- compatNames.set('format_bold', 'bold');
160
- compatNames.set('format_clear', 'remove-formatting');
161
- compatNames.set('format_indent_increase', 'indent-increase');
162
- compatNames.set('format_indent_decrease', 'indent-decrease');
163
- compatNames.set('format_italic', 'italic');
164
- compatNames.set('format_list_bulleted', 'list');
165
- compatNames.set('format_list_numbered', 'badge-help');
166
- compatNames.set('format_quote', 'quote');
167
- compatNames.set('format_strikethrough', 'strikethrough');
168
- compatNames.set('format_underlined', 'underline');
169
- compatNames.set('fullscreen', 'maximize-2');
170
- compatNames.set('grid_on', 'file-spreadsheet');
171
- compatNames.set('handshake', 'handshake');
172
- compatNames.set('help', 'circle-help');
173
- compatNames.set('history', 'history');
174
- compatNames.set('home', 'house');
175
- compatNames.set('import_contacts', 'book');
176
- compatNames.set('insert_photo', 'file-image');
177
- compatNames.set('keyboard', 'keyboard');
178
- compatNames.set('link', 'link-2');
179
- compatNames.set('link_off', 'link-2-off');
180
- compatNames.set('live_tv', 'tv-minimal-play');
181
- compatNames.set('local_offer', 'tag');
182
- compatNames.set('manage_search', 'text-search');
183
- compatNames.set('menu_book', 'book-marked');
184
- compatNames.set('more_horiz', 'ellipsis');
185
- compatNames.set('music_note', 'music-2');
186
- compatNames.set('notes', 'notebook-text');
187
- compatNames.set('ondemand_video', 'video');
188
- compatNames.set('open_with', 'move');
189
- compatNames.set('person', 'user-pen');
190
- compatNames.set('photo', 'file-image');
191
- compatNames.set('photo_camera', 'camera');
192
- compatNames.set('photo_library', 'images');
193
- compatNames.set('picture', 'image-up');
194
- compatNames.set('play', 'square-play');
195
- compatNames.set('playlist_play', 'list-video');
196
- compatNames.set('post_add', 'clipboard-plus');
197
- compatNames.set('question_answer', 'pencil-line');
198
- compatNames.set('rate_review', 'square-pen');
199
- compatNames.set('redo', 'redo');
200
- compatNames.set('remove', 'minus');
201
- compatNames.set('school', 'badge-info');
202
- compatNames.set('search', 'search');
203
- compatNames.set('settings_ethernet', 'chevrons-left-right-ellipsis');
204
- compatNames.set('short_text', 'text');
205
- compatNames.set('slideshow', 'film');
206
- compatNames.set('slow_motion_video', 'list-video');
207
- compatNames.set('subject', 'letter-text');
208
- compatNames.set('textsms', 'message-circle-more');
209
- compatNames.set('theaters', 'clapperboard');
210
- compatNames.set('toc', 'notebook-tabs');
211
- compatNames.set('toggle_off', 'toggle-left');
212
- compatNames.set('toggle_on', 'toggle-right');
213
- compatNames.set('undo', 'undo');
214
- compatNames.set('vertical_align_bottom', 'subscript');
215
- compatNames.set('vertical_align_top', 'superscript');
216
- compatNames.set('view_compact', 'layout-panel-top');
217
- compatNames.set('volume_up', 'volume-2');
218
- compatNames.set('warning', 'triangle-alert');
219
- compatNames.set('wb_incandescent', 'lightbulb');
220
- compatNames.set('widgets', 'blocks');
221
- compatNames.set('zap', 'zap');
222
- compatNames.forEach((value, key) => {
223
- addBase({
224
- /* this is the default icon when no mapped icon is found */
225
- [`[data-icon],[data-icon-name],[data-icon-button-name]`]: {
226
- '--compat-icon': `'${icons['circle-dashed'].encodedCode}'`,
227
- '--compat-icon-via-mask': `url("data:image/svg+xml,${encodeSVG(addNameSpace(svgs['CircleDashed']))}")`,
228
- },
229
- [`html [data-icon="${key}"],html [data-icon-name="${key}"],html [data-icon-button-name="${key}"]`]: {
230
- // tslint:disable-next-line
231
- '--compat-icon': `'${icons[value].encodedCode}'`,
232
- '--compat-icon-via-mask': `url("data:image/svg+xml,${encodeSVG(addNameSpace(svgs[kebabToPascal(value)]))}")`,
233
- },
234
- });
235
- });
236
107
  }, {
237
108
  theme: {
238
109
  iconSize: {
@@ -1,15 +1,10 @@
1
1
  import plugin from 'tailwindcss/plugin'
2
2
  import icons from 'lucide-static/font/info.json'
3
3
  import * as LucideExports from 'lucide-static/dist/cjs/lucide-static'
4
+ import { pascalToKebab } from './util/string'
5
+ import { addNameSpaceXML, encodeSVG } from './util/svg'
4
6
  declare let module: any
5
7
 
6
- interface LucideTypes {
7
- encodedCode: string
8
- prefix: string
9
- className: string
10
- unicode: string
11
- }
12
-
13
8
  /**
14
9
  * Lucide Icons | https://lucide.dev/icons/
15
10
  * Each icon is designed on a 24x24 grid with an emphasis on simplicity, consistency and readability.
@@ -50,36 +45,8 @@ for (const [key, value] of Object.entries(LucideExports)) {
50
45
  }
51
46
  }
52
47
 
53
- function addNameSpace(data: string): string {
54
- if (data.indexOf(`http://www.w3.org/2000/svg`) < 0) {
55
- data = data.replace(/<svg/g, `<svg xmlns='http://www.w3.org/2000/svg'`)
56
- }
57
- return data
58
- }
59
-
60
- function pascalToKebab(str: string): string {
61
- return str
62
- .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
63
- .replace(/([A-Za-z])([0-9])/g, '$1-$2')
64
- .toLowerCase()
65
- }
66
-
67
- function kebabToPascal(str: string): string {
68
- return str
69
- .split('-')
70
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
71
- .join('')
72
- }
73
-
74
- function encodeSVG(data: string): string {
75
- data = data.replace(/"/g, `'`)
76
- data = data.replace(/>\s{1,}</g, `><`)
77
- data = data.replace(/\s{2,}/g, ` `)
78
- return data.replace(symbols, encodeURIComponent)
79
- }
80
-
81
48
  module.exports = plugin(
82
- function ({ addBase, addComponents, matchUtilities, theme }) {
49
+ function ({ addComponents, matchUtilities, theme }) {
83
50
  const size = 'var(--Icon-size)'
84
51
  const prefix = '.btu-icon-'
85
52
 
@@ -93,7 +60,7 @@ module.exports = plugin(
93
60
  },
94
61
  [`${prefix}via-mask-${pascalToKebab(key)}`]: {
95
62
  '--size': '20px',
96
- '--Icon-svg': `url("data:image/svg+xml,${encodeSVG(addNameSpace(svg))}")`,
63
+ '--Icon-svg': `url("data:image/svg+xml,${encodeSVG(addNameSpaceXML(svg))}")`,
97
64
  mask: 'var(--Icon-svg) center / contain no-repeat',
98
65
  'aspect-ratio': '1',
99
66
  'inline-size': 'var(--Icon-size, --size)',
@@ -154,116 +121,6 @@ module.exports = plugin(
154
121
  },
155
122
  { values: theme('iconSize') },
156
123
  )
157
-
158
- // Compat v4 Icons:
159
- // Icon names which are Google Material icons mapped to a lucide equivalent to support the legacy markup.
160
- const compatNames = new Map()
161
- compatNames.set('arrow_downward', 'arrow-down')
162
- compatNames.set('arrow_upward', 'arrow-up')
163
- compatNames.set('assessment', 'file-chart-pie')
164
- compatNames.set('assignment', 'clipboard-check')
165
- compatNames.set('attachment', 'file')
166
- compatNames.set('auto_stories', 'book')
167
- compatNames.set('ballot', 'shield-question')
168
- compatNames.set('border_all', 'table-2')
169
- compatNames.set('cancel', 'circle-x')
170
- compatNames.set('chat_bubble', 'message-circle')
171
- compatNames.set('check_circle', 'circle-check-big')
172
- compatNames.set('chrome_reader_mode', 'table-properties')
173
- compatNames.set('class', 'book-type')
174
- compatNames.set('close', 'x')
175
- compatNames.set('code', 'code')
176
- compatNames.set('comment', 'message-circle-plus')
177
- compatNames.set('comments_disabled', 'message-circle-x')
178
- compatNames.set('create_new_folder', 'boxes')
179
- compatNames.set('description', 'file-text')
180
- compatNames.set('edit', 'pencil')
181
- compatNames.set('error', 'circle-alert')
182
- compatNames.set('expand_more', 'chevrons-up-down')
183
- compatNames.set('expand_less', 'chevrons-down-up')
184
- compatNames.set('feed', 'scroll-text')
185
- compatNames.set('format_align_center', 'align-center')
186
- compatNames.set('format_align_left', 'align-left')
187
- compatNames.set('format_align_right', 'align-right')
188
- compatNames.set('format_bold', 'bold')
189
- compatNames.set('format_clear', 'remove-formatting')
190
- compatNames.set('format_indent_increase', 'indent-increase')
191
- compatNames.set('format_indent_decrease', 'indent-decrease')
192
- compatNames.set('format_italic', 'italic')
193
- compatNames.set('format_list_bulleted', 'list')
194
- compatNames.set('format_list_numbered', 'badge-help')
195
- compatNames.set('format_quote', 'quote')
196
- compatNames.set('format_strikethrough', 'strikethrough')
197
- compatNames.set('format_underlined', 'underline')
198
- compatNames.set('fullscreen', 'maximize-2')
199
- compatNames.set('grid_on', 'file-spreadsheet')
200
- compatNames.set('handshake', 'handshake')
201
- compatNames.set('help', 'circle-help')
202
- compatNames.set('history', 'history')
203
- compatNames.set('home', 'house')
204
- compatNames.set('import_contacts', 'book')
205
- compatNames.set('insert_photo', 'file-image')
206
- compatNames.set('keyboard', 'keyboard')
207
- compatNames.set('link', 'link-2')
208
- compatNames.set('link_off', 'link-2-off')
209
- compatNames.set('live_tv', 'tv-minimal-play')
210
- compatNames.set('local_offer', 'tag')
211
- compatNames.set('manage_search', 'text-search')
212
- compatNames.set('menu_book', 'book-marked')
213
- compatNames.set('more_horiz', 'ellipsis')
214
- compatNames.set('music_note', 'music-2')
215
- compatNames.set('notes', 'notebook-text')
216
- compatNames.set('ondemand_video', 'video')
217
- compatNames.set('open_with', 'move')
218
- compatNames.set('person', 'user-pen')
219
- compatNames.set('photo', 'file-image')
220
- compatNames.set('photo_camera', 'camera')
221
- compatNames.set('photo_library', 'images')
222
- compatNames.set('picture', 'image-up')
223
- compatNames.set('play', 'square-play')
224
- compatNames.set('playlist_play', 'list-video')
225
- compatNames.set('post_add', 'clipboard-plus')
226
- compatNames.set('question_answer', 'pencil-line')
227
- compatNames.set('rate_review', 'square-pen')
228
- compatNames.set('redo', 'redo')
229
- compatNames.set('remove', 'minus')
230
- compatNames.set('school', 'badge-info')
231
- compatNames.set('search', 'search')
232
- compatNames.set('settings_ethernet', 'chevrons-left-right-ellipsis')
233
- compatNames.set('short_text', 'text')
234
- compatNames.set('slideshow', 'film')
235
- compatNames.set('slow_motion_video', 'list-video')
236
- compatNames.set('subject', 'letter-text')
237
- compatNames.set('textsms', 'message-circle-more')
238
- compatNames.set('theaters', 'clapperboard')
239
- compatNames.set('toc', 'notebook-tabs')
240
- compatNames.set('toggle_off', 'toggle-left')
241
- compatNames.set('toggle_on', 'toggle-right')
242
- compatNames.set('undo', 'undo')
243
- compatNames.set('vertical_align_bottom', 'subscript')
244
- compatNames.set('vertical_align_top', 'superscript')
245
- compatNames.set('view_compact', 'layout-panel-top')
246
- compatNames.set('volume_up', 'volume-2')
247
- compatNames.set('warning', 'triangle-alert')
248
- compatNames.set('wb_incandescent', 'lightbulb')
249
- compatNames.set('widgets', 'blocks')
250
- compatNames.set('zap', 'zap')
251
-
252
- compatNames.forEach((value: string, key) => {
253
- addBase({
254
- /* this is the default icon when no mapped icon is found */
255
- [`[data-icon],[data-icon-name],[data-icon-button-name]`]: {
256
- '--compat-icon': `'${icons['circle-dashed'].encodedCode}'`,
257
- '--compat-icon-via-mask': `url("data:image/svg+xml,${encodeSVG(addNameSpace(svgs['CircleDashed']))}")`,
258
- },
259
- [`html [data-icon="${key}"],html [data-icon-name="${key}"],html [data-icon-button-name="${key}"]`]:
260
- {
261
- // tslint:disable-next-line
262
- '--compat-icon': `'${(icons as Record<string, LucideTypes>)[value].encodedCode}'`,
263
- '--compat-icon-via-mask': `url("data:image/svg+xml,${encodeSVG(addNameSpace(svgs[kebabToPascal(value)]))}")`,
264
- },
265
- })
266
- })
267
124
  },
268
125
  {
269
126
  theme: {
@@ -0,0 +1,14 @@
1
+ // Given "WaterBalloon", returns "water-balloon"
2
+ export function pascalToKebab(str) {
3
+ return str
4
+ .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
5
+ .replace(/([A-Za-z])([0-9])/g, '$1-$2')
6
+ .toLowerCase();
7
+ }
8
+ // Given "water-balloon", returns "WaterBalloon"
9
+ export function kebabToPascal(str) {
10
+ return str
11
+ .split('-')
12
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
13
+ .join('');
14
+ }
@@ -0,0 +1,13 @@
1
+ const symbols = /[\r\n%#()<>?[\\\]^`{|}]/g;
2
+ export function addNameSpaceXML(data) {
3
+ if (data.indexOf(`http://www.w3.org/2000/svg`) < 0) {
4
+ data = data.replace(/<svg/g, `<svg xmlns='http://www.w3.org/2000/svg'`);
5
+ }
6
+ return data;
7
+ }
8
+ export function encodeSVG(data) {
9
+ data = data.replace(/"/g, `'`);
10
+ data = data.replace(/>\s{1,}</g, `><`);
11
+ data = data.replace(/\s{2,}/g, ` `);
12
+ return data.replace(symbols, encodeURIComponent);
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspot/ui",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.3",
4
4
  "license": "UNLICENSED",
5
5
  "description": "A UI library for building Brightspot CMS components.",
6
6
  "main": "./dist/tailwind.config.ts",