@atom-learning/components 2.63.0 → 2.63.1
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/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
## [2.63.1](https://github.com/Atom-Learning/components/compare/v2.63.0...v2.63.1) (2023-07-26)
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
###
|
|
4
|
+
### Bug Fixes
|
|
5
5
|
|
|
6
|
-
*
|
|
6
|
+
* move left arrow in TabsTriggerList so always over list, negate tabIndex as not useful to tab on ([92c2738](https://github.com/Atom-Learning/components/commit/92c2738b94c92ac5599e0579f5ac3005b72e3467))
|
|
7
7
|
|
|
8
8
|
# [1.4.0](https://github.com/Atom-Learning/components/compare/v1.3.0...v1.4.0) (2022-04-11)
|
|
9
9
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ChevronLeft as y,ChevronRight as C}from"@atom-learning/icons";import{List as k}from"@radix-ui/react-tabs";import t from"react";import{ColorScheme as v}from"../../experiments/color-scheme/ColorScheme.js";import{styled as i}from"../../stitches.js";import{useCallbackRefState as
|
|
1
|
+
import{ChevronLeft as y,ChevronRight as C}from"@atom-learning/icons";import{List as k}from"@radix-ui/react-tabs";import t from"react";import{ColorScheme as v}from"../../experiments/color-scheme/ColorScheme.js";import{styled as i}from"../../stitches.js";import{useCallbackRefState as x}from"../../utilities/hooks/useCallbackRef.js";import{useScrollPosition as E}from"../../utilities/hooks/useScrollPosition.js";import{useSize as S}from"../../utilities/hooks/useSize.js";import{ActionIcon as W}from"../action-icon/ActionIcon.js";import{Icon as s}from"../icon/Icon.js";const w=i(v,{position:"relative",borderBottom:"1px solid $base4",width:"100%"}),I=i(k,{flexShrink:0,display:"flex",width:"100%",overflowX:"auto","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"}),a=i(W,{height:"100% !important",position:"absolute",top:"50%",transform:"translateY(-50%)",cursor:"pointer",background:"$base1 !important",color:"$interactive1 !important",borderRadius:0,opacity:.9}),n=.8,c=({children:m,colorScheme:d={},...h})=>{const[e,f]=x(),{width:p}=S({element:e,delay:500}),{left:o}=E({element:e,delay:100,delayMethod:"debounce"}),r=t.useMemo(()=>e?e.scrollWidth>e.clientWidth:!1,[p,e]),b=t.useMemo(()=>r?o>0:!1,[o,r]),u=t.useMemo(()=>!e||!r?!1:e.scrollWidth-o-e.clientWidth>1,[e,o,r]),l=t.useCallback(g=>{!e||e.scroll({left:e.scrollLeft+e.clientWidth*g,behavior:"smooth"})},[e]);return t.createElement(w,{base:"grey1",accent:"blue1",interactive:"hiContrast",...d,...h},t.createElement(I,{ref:f},m),b&&t.createElement(a,{label:"scroll left",size:"md",css:{left:0},onClick:()=>l(-n),tabIndex:-1},t.createElement(s,{is:y})),u&&t.createElement(a,{label:"scroll right",size:"md",css:{right:0},onClick:()=>l(n),tabIndex:-1},t.createElement(s,{is:C})))};c.displayName="TabsTriggerList";export{c as TabsTriggerList};
|
|
2
2
|
//# sourceMappingURL=TabsTriggerList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabsTriggerList.js","sources":["../../../src/components/tabs/TabsTriggerList.tsx"],"sourcesContent":["import { ChevronLeft, ChevronRight } from '@atom-learning/icons'\nimport { List } from '@radix-ui/react-tabs'\nimport React from 'react'\n\nimport { ColorScheme, TcolorScheme } from '~/experiments/color-scheme'\nimport { styled } from '~/stitches'\nimport { useCallbackRefState } from '~/utilities/hooks/useCallbackRef'\nimport { useScrollPosition } from '~/utilities/hooks/useScrollPosition'\nimport { useSize } from '~/utilities/hooks/useSize'\n\nimport { ActionIcon } from '../action-icon'\nimport { Icon } from '../icon'\n\nconst StyledContainer = styled(ColorScheme, {\n position: 'relative',\n borderBottom: '1px solid $base4',\n width: '100%'\n})\n\nconst StyledTriggerList = styled(List, {\n flexShrink: 0,\n display: 'flex',\n width: '100%',\n overflowX: 'auto',\n '&::-webkit-scrollbar': { display: 'none' },\n scrollbarWidth: 'none'\n})\n\nconst StyledChevronActionIcon = styled(ActionIcon, {\n height: '100% !important',\n position: 'absolute',\n top: '50%',\n transform: 'translateY(-50%)',\n cursor: 'pointer',\n background: '$base1 !important',\n color: '$interactive1 !important',\n borderRadius: 0,\n opacity: 0.9\n})\n\nconst SCROLL_STEP = 0.8 // Used to scroll 80% of clientWidth\n\nexport const TabsTriggerList: React.FC<\n React.ComponentProps<typeof StyledTriggerList> & {\n colorScheme?: TcolorScheme\n }\n> = ({ children, colorScheme = {}, ...rest }) => {\n const [listRef, setListRefCallback] = useCallbackRefState()\n\n const { width } = useSize({ element: listRef, delay: 500 })\n const { left } = useScrollPosition({\n element: listRef,\n delay: 100,\n delayMethod: 'debounce'\n })\n\n const canScrollXAxis = React.useMemo(() => {\n if (!listRef) return false\n return listRef.scrollWidth > listRef.clientWidth\n }, [width, listRef])\n\n const canScrollLeft = React.useMemo(() => {\n if (!canScrollXAxis) return false\n return left > 0\n }, [left, canScrollXAxis])\n\n const canScrollRight = React.useMemo(() => {\n if (!listRef || !canScrollXAxis) return false\n return listRef.scrollWidth - left - listRef.clientWidth > 1 // 1 rather than 0 to account for sub-pixel widths and calculations\n }, [listRef, left, canScrollXAxis])\n\n const scrollList = React.useCallback(\n (stepModifier) => {\n if (!listRef) return\n listRef.scroll({\n left: listRef.scrollLeft + listRef.clientWidth * stepModifier,\n behavior: 'smooth'\n })\n },\n [listRef]\n )\n\n return (\n <StyledContainer\n base=\"grey1\"\n accent=\"blue1\"\n interactive=\"hiContrast\"\n {...colorScheme}\n {...rest}\n >\n {canScrollLeft && (\n <StyledChevronActionIcon\n label=\"scroll left\"\n size=\"md\"\n css={{\n left: 0\n }}\n onClick={() => scrollList(-SCROLL_STEP)}\n >\n <Icon is={ChevronLeft} />\n </StyledChevronActionIcon>\n )}\n\n
|
|
1
|
+
{"version":3,"file":"TabsTriggerList.js","sources":["../../../src/components/tabs/TabsTriggerList.tsx"],"sourcesContent":["import { ChevronLeft, ChevronRight } from '@atom-learning/icons'\nimport { List } from '@radix-ui/react-tabs'\nimport React from 'react'\n\nimport { ColorScheme, TcolorScheme } from '~/experiments/color-scheme'\nimport { styled } from '~/stitches'\nimport { useCallbackRefState } from '~/utilities/hooks/useCallbackRef'\nimport { useScrollPosition } from '~/utilities/hooks/useScrollPosition'\nimport { useSize } from '~/utilities/hooks/useSize'\n\nimport { ActionIcon } from '../action-icon'\nimport { Icon } from '../icon'\n\nconst StyledContainer = styled(ColorScheme, {\n position: 'relative',\n borderBottom: '1px solid $base4',\n width: '100%'\n})\n\nconst StyledTriggerList = styled(List, {\n flexShrink: 0,\n display: 'flex',\n width: '100%',\n overflowX: 'auto',\n '&::-webkit-scrollbar': { display: 'none' },\n scrollbarWidth: 'none'\n})\n\nconst StyledChevronActionIcon = styled(ActionIcon, {\n height: '100% !important',\n position: 'absolute',\n top: '50%',\n transform: 'translateY(-50%)',\n cursor: 'pointer',\n background: '$base1 !important',\n color: '$interactive1 !important',\n borderRadius: 0,\n opacity: 0.9\n})\n\nconst SCROLL_STEP = 0.8 // Used to scroll 80% of clientWidth\n\nexport const TabsTriggerList: React.FC<\n React.ComponentProps<typeof StyledTriggerList> & {\n colorScheme?: TcolorScheme\n }\n> = ({ children, colorScheme = {}, ...rest }) => {\n const [listRef, setListRefCallback] = useCallbackRefState()\n\n const { width } = useSize({ element: listRef, delay: 500 })\n const { left } = useScrollPosition({\n element: listRef,\n delay: 100,\n delayMethod: 'debounce'\n })\n\n const canScrollXAxis = React.useMemo(() => {\n if (!listRef) return false\n return listRef.scrollWidth > listRef.clientWidth\n }, [width, listRef])\n\n const canScrollLeft = React.useMemo(() => {\n if (!canScrollXAxis) return false\n return left > 0\n }, [left, canScrollXAxis])\n\n const canScrollRight = React.useMemo(() => {\n if (!listRef || !canScrollXAxis) return false\n return listRef.scrollWidth - left - listRef.clientWidth > 1 // 1 rather than 0 to account for sub-pixel widths and calculations\n }, [listRef, left, canScrollXAxis])\n\n const scrollList = React.useCallback(\n (stepModifier) => {\n if (!listRef) return\n listRef.scroll({\n left: listRef.scrollLeft + listRef.clientWidth * stepModifier,\n behavior: 'smooth'\n })\n },\n [listRef]\n )\n\n return (\n <StyledContainer\n base=\"grey1\"\n accent=\"blue1\"\n interactive=\"hiContrast\"\n {...colorScheme}\n {...rest}\n >\n <StyledTriggerList ref={setListRefCallback}>{children}</StyledTriggerList>\n\n {canScrollLeft && (\n <StyledChevronActionIcon\n label=\"scroll left\"\n size=\"md\"\n css={{\n left: 0\n }}\n onClick={() => scrollList(-SCROLL_STEP)}\n tabIndex={-1}\n >\n <Icon is={ChevronLeft} />\n </StyledChevronActionIcon>\n )}\n\n {canScrollRight && (\n <StyledChevronActionIcon\n label=\"scroll right\"\n size=\"md\"\n css={{\n right: 0\n }}\n onClick={() => scrollList(SCROLL_STEP)}\n tabIndex={-1}\n >\n <Icon is={ChevronRight} />\n </StyledChevronActionIcon>\n )}\n </StyledContainer>\n )\n}\n\nTabsTriggerList.displayName = 'TabsTriggerList'\n"],"names":["StyledContainer","styled","ColorScheme","StyledTriggerList","List","StyledChevronActionIcon","ActionIcon","SCROLL_STEP","TabsTriggerList","children","colorScheme","rest","listRef","setListRefCallback","useCallbackRefState","width","useSize","left","useScrollPosition","canScrollXAxis","React","canScrollLeft","canScrollRight","scrollList","stepModifier","Icon","ChevronLeft","ChevronRight"],"mappings":"sjBAaA,MAAMA,EAAkBC,EAAOC,EAAa,CAC1C,SAAU,WACV,aAAc,mBACd,MAAO,MACT,CAAC,EAEKC,EAAoBF,EAAOG,EAAM,CACrC,WAAY,EACZ,QAAS,OACT,MAAO,OACP,UAAW,OACX,uBAAwB,CAAE,QAAS,MAAO,EAC1C,eAAgB,MAClB,CAAC,EAEKC,EAA0BJ,EAAOK,EAAY,CACjD,OAAQ,kBACR,SAAU,WACV,IAAK,MACL,UAAW,mBACX,OAAQ,UACR,WAAY,oBACZ,MAAO,2BACP,aAAc,EACd,QAAS,EACX,CAAC,EAEKC,EAAc,GA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