najwer23morsels 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +7 -2
- package/lib/Slider.js +1 -1
- package/lib/slider/Slider.d.ts +5 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
The npm package najwer23morsels allows you to style its React UI components using native CSS logic, primarily through global CSS variables, enabling full customization without relying on additional styling libraries. This approach means you can control component appearance by simply overriding CSS variables or applying your own CSS rules, maintaining straightforward and native styling workflows. It supports styling flexibility by leveraging standard CSS practices, making it easy to adapt the design system to your own needs while keeping the styling logic simple and native to the web platform.
|
|
2
2
|
|
|
3
3
|
### Global css variables available
|
|
4
4
|
|
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
--najwer23morselsTextBoxColorHover: orange;
|
|
15
15
|
--najwer23morselsTextBoxLineHeight: 1.42857;
|
|
16
16
|
--najwer23morselsTextBoxFontWeight: 400;
|
|
17
|
-
--najwer23morselsTextBoxFontWeightHover: 800
|
|
17
|
+
--najwer23morselsTextBoxFontWeightHover: 800;
|
|
18
|
+
|
|
19
|
+
/* MorselsSlider */
|
|
20
|
+
--najwer23morselsSliderArrowsColorBackground: white;
|
|
21
|
+
--najwer23morselsSliderArrowsColorBorder: black;
|
|
22
|
+
--najwer23morselsSliderArrowsColor: black;
|
|
18
23
|
}
|
|
19
24
|
```
|
package/lib/Slider.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as
|
|
1
|
+
import{jsxs as e,jsx as r}from"react/jsx-runtime";import t,{useState as l,useRef as n,useEffect as o,useCallback as s}from"react";import{s as i}from"./style-inject.es-BnTDb6vU.js";var a={sliderContainer:"Slider-module_sliderContainer__o7YCe",slideWrapper:"Slider-module_slideWrapper__Jll6Y",slide:"Slider-module_slide__G9U2-",sliderBtnControl:"Slider-module_sliderBtnControl__dtMGL",btn:"Slider-module_btn__FGB-r"};i("@layer najwer23morselsSlider{.Slider-module_sliderContainer__o7YCe{display:flex;flex-direction:column;gap:10px;height:100%;position:relative;user-select:none;width:100%}.Slider-module_slideWrapper__Jll6Y{height:100%;overflow:hidden;position:relative;width:100%;will-change:transform}.Slider-module_slide__G9U2-{height:100%;overflow:hidden;position:absolute;top:0;will-change:transform;&>*{height:100%;width:100%}}.Slider-module_sliderBtnControl__dtMGL{align-items:center;display:flex;height:100%;left:0;padding:0 25px;pointer-events:none;position:absolute;right:0;z-index:100}.Slider-module_btn__FGB-r{-webkit-touch-callout:none;-webkit-tap-highlight-color:rgba(0,0,0,0);background-color:var(--najwer23morselsSliderArrowsColorBackground,var(--abgc,#fff));border:1px solid var(--najwer23morselsSliderArrowsColorBorder,var(--abc,#000));border-radius:50%;color:var(--najwer23morselsSliderArrowsColor,var(--ac,#000));cursor:pointer;display:flex;left:50%;padding:10px;pointer-events:auto;transition:all .2s linear;transition:background-color .3s,box-shadow .3s;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;@media (hover:hover) and (pointer:fine){&:hover{box-shadow:0 4px 8px 0 rgba(0,0,0,.24),0 6px 20px 0 rgba(0,0,0,.19);filter:brightness(.95)}}}}");const d=(e,r,l=!1)=>(l?e.slice(0,r):e.slice(-r)).map((e,r)=>t.cloneElement(e,{key:`${l?"clone-first":"clone-last"}-${r}`,className:e.props.className})),c=({isCircular:i=!1,children:c,className:h,arrowsColor:m,arrowsColorBackground:u,arrowsColorBorder:p})=>{const f=t.Children.toArray(c).filter(t.isValidElement),[g,w]=l(i&&f.length>=2?2:0),[v,b]=l(!1),[x,_]=l(0),[y,C]=l(0),S=n(null),k=n([]),N=n(null),B=i&&f.length>=2?[...d(f,2,!1),...f.map((e,r)=>t.cloneElement(e,{key:e.key??r,className:e.props.className})),...d(f,2,!0)]:f.map((e,r)=>t.cloneElement(e,{key:e.key??r,className:e.props.className}));k.current.length!==B.length&&(k.current=Array(B.length).fill(null)),o(()=>{w(i&&f.length>=2?2:0)},[i,f.length]);const j=s(()=>{const e=S.current;if(!e)return;const r=k.current[0];if(!r)return;const t=window.getComputedStyle(r);_(r.offsetWidth+parseFloat(t.marginLeft)+parseFloat(t.marginRight)),C(e.offsetWidth)},[]);o(()=>{j();const e=()=>{null!==N.current&&clearTimeout(N.current),N.current=window.setTimeout(()=>{j(),i||b(!0)},150)};return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e),null!==N.current&&clearTimeout(N.current)}},[j]),o(()=>{const e=x+10;k.current.forEach((r,t)=>{if(r)if(i){const l=(t-g)*e+(y-x)/2;r.style.transition=v?"transform 0.4s cubic-bezier(.4,0,.2,1)":"none",r.style.transform=`translateX(${l}px)`,r.style.left=""}else{const l=e*(t-g)+(y-x)/2;if(v){const e=parseFloat(r.style.left||"0");r.animate([{left:`${e}px`},{left:`${l}px`}],{duration:400,easing:"ease-out",fill:"forwards"}).finished.then(()=>{r.style.left=`${l}px`,b(!1)})}else r.style.left=`${l}px`;r.style.transition="none",r.style.transform=""}})},[g,x,y,v,B.length,i]),o(()=>{if(!i||!v)return;const e=k.current.length,r=k.current[e-1];if(!r)return;const t=()=>{let l=g;1===g?l=e-3:g===e-2&&(l=2),l!==g&&w(l),b(!1),r.removeEventListener("transitionend",t)};return r.addEventListener("transitionend",t),()=>r.removeEventListener("transitionend",t)},[g,i,v]);return e("div",{className:[a.sliderContainer,"MorselsSlider",h].filter(Boolean).join(" "),style:{"--ac":m,"--abgc":u,"--abc":p},children:[e("div",{className:[a.sliderBtnControl,"MorselsSliderControl",h].join(" "),style:{justifyContent:i?"space-between":0===g?"flex-end":g===f.length-1?"flex-start":"space-between"},children:[(i&&f.length>1||0!==g)&&r("button",{className:a.btn,onClick:()=>{v||(b(!0),w(i?e=>e-1:e=>Math.max(e-1,0)))},disabled:v,children:r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 320 512",width:"24",height:"24",fill:"currentColor",children:r("path",{d:"M41.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.3 256 246.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z"})})}),(i&&f.length>1||g!==f.length-1)&&r("button",{className:a.btn,onClick:()=>{v||(b(!0),w(i?e=>e+1:e=>Math.min(e+1,B.length-1)))},disabled:v,children:r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 320 512",width:"24",height:"24",fill:"currentColor",children:r("path",{d:"M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z"})})})]}),r("div",{className:[a.slideWrapper,"MorselsSliderWrapper",h].join(" "),ref:S,children:B.map((e,t)=>r("div",{ref:e=>{k.current[t]=e},className:`${a.slide}`,style:{width:f.length>1?"calc(100% - 100px)":"100%"},"aria-hidden":g!==t,children:e},e.key??t))})]})};c.displayName="Slider";export{c as Slider};
|
package/lib/slider/Slider.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
|
|
2
|
+
interface SliderProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
3
|
isCircular?: boolean;
|
|
4
4
|
children: ReactNode;
|
|
5
|
-
|
|
5
|
+
arrowsColor?: string;
|
|
6
|
+
arrowsColorBackground?: string;
|
|
7
|
+
arrowsColorBorder?: string;
|
|
8
|
+
}
|
|
6
9
|
export declare const Slider: React.FC<SliderProps>;
|
|
7
10
|
export {};
|