@ably/ui 14.0.0-dev.1939f45 → 14.0.0-dev.2944826
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.
- package/core/Accordion.js +1 -1
- package/core/Code.js +1 -1
- package/core/Expander.js +1 -1
- package/core/Table/TableCell.js +1 -1
- package/core/utils/syntax-highlighter.css +0 -3
- package/package.json +1 -3
- package/src/core/Accordion.tsx +1 -1
- package/src/core/Code.tsx +0 -1
- package/src/core/Expander.tsx +16 -7
- package/src/core/Table/TableCell.tsx +1 -1
- package/src/core/utils/syntax-highlighter.css +0 -3
package/core/Accordion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import React,{useState}from"react";import Icon from"./Icon";const AccordionRow=({name,children,index,setActiveIndex,active,topBorder,bottomBorder,last,arrowIcon})=>{let iconActive,iconInactive;const handleSetIndex=()=>{setActiveIndex(index)};if(arrowIcon){iconActive=React.createElement(Icon,{name:"icon-gui-disclosure-arrow",color:"text-dark-grey",size:"1.5rem",additionalCSS:"-rotate-90"});iconInactive=React.createElement(Icon,{name:"icon-gui-disclosure-arrow",color:"text-dark-grey",size:"1.5rem",additionalCSS:"rotate-90"})}else{iconActive=React.createElement(Icon,{name:"icon-gui-minus",color:"text-dark-grey",size:"1.5rem"});iconInactive=React.createElement(Icon,{name:"icon-gui-plus",color:"text-dark-grey",size:"1.5rem"})}return React.createElement("div",{className:`border-mid-grey ${last&&!bottomBorder?"":"border-b"} ${topBorder?"border-t":""}`},React.createElement("button",{type:"button",onClick:handleSetIndex,className:`flex w-full px-0 focus:outline-none py-20`},React.createElement("span",{className:"ui-text-p1
|
|
1
|
+
import React,{useState}from"react";import Icon from"./Icon";const AccordionRow=({name,children,index,setActiveIndex,active,topBorder,bottomBorder,last,arrowIcon})=>{let iconActive,iconInactive;const handleSetIndex=()=>{setActiveIndex(index)};if(arrowIcon){iconActive=React.createElement(Icon,{name:"icon-gui-disclosure-arrow",color:"text-dark-grey",size:"1.5rem",additionalCSS:"-rotate-90"});iconInactive=React.createElement(Icon,{name:"icon-gui-disclosure-arrow",color:"text-dark-grey",size:"1.5rem",additionalCSS:"rotate-90"})}else{iconActive=React.createElement(Icon,{name:"icon-gui-minus",color:"text-dark-grey",size:"1.5rem"});iconInactive=React.createElement(Icon,{name:"icon-gui-plus",color:"text-dark-grey",size:"1.5rem"})}return React.createElement("div",{className:`border-mid-grey ${last&&!bottomBorder?"":"border-b"} ${topBorder?"border-t":""}`},React.createElement("button",{type:"button",onClick:handleSetIndex,className:`flex w-full px-0 focus:outline-none py-20`},React.createElement("span",{className:"ui-text-p1 font-bold text-left mr-8"},name),React.createElement("span",{className:"ml-auto"},active?iconActive:iconInactive)),React.createElement("section",{className:"ui-text-p2 transition-all overflow-hidden",style:{maxHeight:active?"500px":"0",paddingBottom:active?"1.5rem":"0"}},children))};const Accordion=({data,id="id-accordion",topBorder,bottomBorder,arrowIcon,autoClose})=>{const[activeIndexes,setActiveIndexes]=useState([]);const handleSetIndex=index=>{const currentIndexIsActive=activeIndexes.includes(index);if(autoClose){setActiveIndexes(currentIndexIsActive?[]:[index])}else{setActiveIndexes(currentIndexIsActive?activeIndexes.filter(i=>i!==index):[...activeIndexes,index])}};return React.createElement("div",{className:"ui-grid-mx max-w-screen-sm sm:mx-auto",id:id},data.map((item,currentIndex)=>{return React.createElement(AccordionRow,{key:item.name,name:item.name,arrowIcon:arrowIcon,index:currentIndex,last:data.length===currentIndex+1,topBorder:topBorder&¤tIndex===0,bottomBorder:bottomBorder&&data.length===currentIndex+1,active:activeIndexes.includes(currentIndex),setActiveIndex:handleSetIndex},item.content)}))};export default Accordion;
|
package/core/Code.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import React from"react";import
|
|
1
|
+
import React from"react";import{highlightSnippet,registerDefaultLanguages}from"./utils/syntax-highlighter";import languagesRegistry from"./utils/syntax-highlighter-registry";registerDefaultLanguages(languagesRegistry);const Code=({language,snippet,textSize="ui-text-code",padding="p-32",additionalCSS=""})=>{var _highlightSnippet;const HTMLraw=(_highlightSnippet=highlightSnippet(language,`${snippet}`.trim()))!==null&&_highlightSnippet!==void 0?_highlightSnippet:"";const className=`language-${language} ${textSize}`;return React.createElement("div",{className:`hljs overflow-auto ${padding} ${additionalCSS}`,"data-id":"code"},React.createElement("pre",{lang:language},React.createElement("code",{className:className,dangerouslySetInnerHTML:{__html:HTMLraw}})))};export default Code;
|
package/core/Expander.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import React,{useEffect,useRef,useState}from"react";const Expander=({
|
|
1
|
+
import React,{useEffect,useRef,useState}from"react";const Expander=({heightThreshold=200,className,fadeClassName,children})=>{const innerRef=useRef(null);const[showControls,setShowControls]=useState(false);const[height,setHeight]=useState(heightThreshold);const[expanded,setExpanded]=useState(false);useEffect(()=>{var _innerRef_current;var _innerRef_current_clientHeight;const contentHeight=(_innerRef_current_clientHeight=(_innerRef_current=innerRef.current)===null||_innerRef_current===void 0?void 0:_innerRef_current.clientHeight)!==null&&_innerRef_current_clientHeight!==void 0?_innerRef_current_clientHeight:heightThreshold;if(contentHeight<heightThreshold){setHeight("auto")}else if(expanded){setHeight(contentHeight)}else{setHeight(heightThreshold)}setShowControls(contentHeight>=heightThreshold)},[heightThreshold,expanded]);return React.createElement(React.Fragment,null,React.createElement("div",{style:{height},className:`overflow-hidden transition-all relative ${className!==null&&className!==void 0?className:""}`},showControls&&!expanded&&React.createElement("div",{className:`h-64 w-full bg-gradient-to-t from-white to-transparent absolute bottom-0 left-0 right-0 ${fadeClassName!==null&&fadeClassName!==void 0?fadeClassName:""}`}),React.createElement("div",{ref:innerRef},children)),showControls&&React.createElement("div",{onClick:()=>setExpanded(!expanded),onKeyDown:e=>e.key==="Enter"&&setExpanded(!expanded),tabIndex:0,className:"mt-16 cursor-pointer font-bold text-gui-blue-default-light hover:text-gui-blue-hover-light active:text-gui-blue-active-light focus:text-gui-blue-focus"},expanded?"View less -":"View all +"))};export default Expander;
|
package/core/Table/TableCell.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from"react";import Icon from"../Icon";const Supported=()=>React.createElement(Icon,{name:"icon-gui-check-circled-fill",size:"1.5rem",color:"text-gui-success",additionalCSS:"flex-grow-0 flex-shrink-0","data-testid":"supported-icon"});const Unsupported=()=>React.createElement(Icon,{name:"icon-gui-cross-circled-fill",size:"1.5rem",color:"text-gui-error",additionalCSS:"flex-grow-0 flex-shrink-0","data-testid":"unsupported-icon"});const Partial=()=>React.createElement(Icon,{name:"icon-gui-partial",size:"1.5rem",additionalCSS:"flex-grow-0 flex-shrink-0","data-testid":"partial-icon"});const LabelCell=({children,...rest})=>{var _rest_className;const classes=`
|
|
2
|
-
ui-text-p1
|
|
2
|
+
ui-text-p1 font-bold pt-24 pb-8 border-light-grey sm:p-24 sm:relative sm:top-2 flex sm:table-cell ${(_rest_className=rest===null||rest===void 0?void 0:rest.className)!==null&&_rest_className!==void 0?_rest_className:""}
|
|
3
3
|
`;return React.createElement("td",{...rest,className:classes},children)};const TableCell=({children,isRowHeader,...rest})=>{var _rest_className;return React.createElement("td",{...rest,className:`
|
|
4
4
|
border-light-grey sm:p-24 leading-none flex sm:table-cell
|
|
5
5
|
${isRowHeader?"rounded-l-none rounded-r sm:rounded-lg py-20 px-24":"py-6"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
@tailwind base;
|
|
2
|
-
@tailwind components;
|
|
3
|
-
|
|
4
1
|
@layer base {
|
|
5
2
|
@import url("https://fonts.googleapis.com/css2?family=Source+Code+Pro:ital,wght@0,600;0,700;1,600;1,700&display=swap");
|
|
6
3
|
@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@100;200;300;400;500;600;700;800&display=swap");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ably/ui",
|
|
3
|
-
"version": "14.0.0-dev.
|
|
3
|
+
"version": "14.0.0-dev.2944826",
|
|
4
4
|
"description": "Home of the Ably design system library ([design.ably.com](https://design.ably.com)). It provides a showcase, development/test environment and a publishing pipeline for different distributables.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,8 +37,6 @@
|
|
|
37
37
|
"eslint-plugin-storybook": "^0.6.15",
|
|
38
38
|
"msw": "1.3.2",
|
|
39
39
|
"msw-storybook-addon": "^1.10.0",
|
|
40
|
-
"postcss": "^8.4.35",
|
|
41
|
-
"postcss-import": "^13.0.0",
|
|
42
40
|
"prettier": "^2.3.0",
|
|
43
41
|
"storybook": "^7.6.4",
|
|
44
42
|
"svg-sprite": "^2.0.4",
|
package/src/core/Accordion.tsx
CHANGED
|
@@ -80,7 +80,7 @@ const AccordionRow = ({
|
|
|
80
80
|
onClick={handleSetIndex}
|
|
81
81
|
className={`flex w-full px-0 focus:outline-none py-20`}
|
|
82
82
|
>
|
|
83
|
-
<span className="ui-text-p1
|
|
83
|
+
<span className="ui-text-p1 font-bold text-left mr-8">{name}</span>
|
|
84
84
|
<span className="ml-auto">{active ? iconActive : iconInactive}</span>
|
|
85
85
|
</button>
|
|
86
86
|
|
package/src/core/Code.tsx
CHANGED
package/src/core/Expander.tsx
CHANGED
|
@@ -1,31 +1,40 @@
|
|
|
1
1
|
import React, { PropsWithChildren, useEffect, useRef, useState } from "react";
|
|
2
2
|
|
|
3
3
|
type ExpanderProps = {
|
|
4
|
-
|
|
4
|
+
heightThreshold?: number;
|
|
5
5
|
className?: string;
|
|
6
6
|
fadeClassName?: string;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
const Expander = ({
|
|
10
|
-
|
|
10
|
+
heightThreshold = 200,
|
|
11
11
|
className,
|
|
12
12
|
fadeClassName,
|
|
13
13
|
children,
|
|
14
14
|
}: PropsWithChildren<ExpanderProps>) => {
|
|
15
15
|
const innerRef = useRef<HTMLDivElement>(null);
|
|
16
|
-
const [
|
|
16
|
+
const [showControls, setShowControls] = useState(false);
|
|
17
|
+
const [height, setHeight] = useState<number | "auto">(heightThreshold);
|
|
17
18
|
const [expanded, setExpanded] = useState(false);
|
|
18
19
|
|
|
19
20
|
useEffect(() => {
|
|
20
|
-
|
|
21
|
-
}, [height, expanded]);
|
|
21
|
+
const contentHeight = innerRef.current?.clientHeight ?? heightThreshold;
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
if (contentHeight < heightThreshold) {
|
|
24
|
+
setHeight("auto");
|
|
25
|
+
} else if (expanded) {
|
|
26
|
+
setHeight(contentHeight);
|
|
27
|
+
} else {
|
|
28
|
+
setHeight(heightThreshold);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
setShowControls(contentHeight >= heightThreshold);
|
|
32
|
+
}, [heightThreshold, expanded]);
|
|
24
33
|
|
|
25
34
|
return (
|
|
26
35
|
<>
|
|
27
36
|
<div
|
|
28
|
-
style={{ height
|
|
37
|
+
style={{ height }}
|
|
29
38
|
className={`overflow-hidden transition-all relative ${className ?? ""}`}
|
|
30
39
|
>
|
|
31
40
|
{showControls && !expanded && (
|
|
@@ -39,7 +39,7 @@ const LabelCell = ({
|
|
|
39
39
|
...rest
|
|
40
40
|
}: PropsWithChildren<React.TdHTMLAttributes<HTMLTableCellElement>>) => {
|
|
41
41
|
const classes = `
|
|
42
|
-
ui-text-p1
|
|
42
|
+
ui-text-p1 font-bold pt-24 pb-8 border-light-grey sm:p-24 sm:relative sm:top-2 flex sm:table-cell ${
|
|
43
43
|
rest?.className ?? ""
|
|
44
44
|
}
|
|
45
45
|
`;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
@tailwind base;
|
|
2
|
-
@tailwind components;
|
|
3
|
-
|
|
4
1
|
@layer base {
|
|
5
2
|
@import url("https://fonts.googleapis.com/css2?family=Source+Code+Pro:ital,wght@0,600;0,700;1,600;1,700&display=swap");
|
|
6
3
|
@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@100;200;300;400;500;600;700;800&display=swap");
|