Skip to content

Commit 2cdd7ab

Browse files
committed
add containcorp images
1 parent 673e15a commit 2cdd7ab

35 files changed

+263
-90
lines changed

package-lock.json

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
"classnames": "^2.3.2",
3333
"date-fns": "^2.29.3",
3434
"debounce": "^1.2.1",
35+
"embla-carousel-autoplay": "^8.6.0",
36+
"embla-carousel-react": "^8.6.0",
3537
"ga-lite": "2.1.4",
3638
"github-slugger": "^1.3.0",
3739
"next": "12.3.2-canary.7",
@@ -48,6 +50,7 @@
4850
"@babel/core": "^7.20.12",
4951
"@babel/plugin-transform-modules-commonjs": "^7.20.11",
5052
"@babel/preset-react": "^7.18.6",
53+
"@lezer/javascript": "0.15.2",
5154
"@mdx-js/mdx": "^2.2.1",
5255
"@types/babel__standalone": "^7.1.4",
5356
"@types/body-scroll-lock": "^3.1.0",
@@ -100,8 +103,7 @@
100103
"tailwindcss": "^3.2.4",
101104
"typescript": "^4.9.5",
102105
"unist-util-visit": "^2.0.3",
103-
"webpack-bundle-analyzer": "^4.7.0",
104-
"@lezer/javascript": "0.15.2"
106+
"webpack-bundle-analyzer": "^4.7.0"
105107
},
106108
"overrides": {
107109
"@lezer/javascript": "0.15.2"
@@ -115,4 +117,4 @@
115117
"*.{js,ts,jsx,tsx,css}": "npm run prettier",
116118
"src/**/*.md": "npm run fix-headings"
117119
}
118-
}
120+
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

src/components/MDX/EmblaCarousel.tsx

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
'use client';
2+
3+
import Autoplay from 'embla-carousel-autoplay';
4+
import useEmblaCarousel from 'embla-carousel-react';
5+
import { Children, PropsWithChildren, ReactElement, cloneElement, useCallback } from 'react';
6+
import styles from './MDXComponents.module.css';
7+
8+
export function EmblaCarousel({ children }: PropsWithChildren) {
9+
const items =
10+
(Children.map(children, (child, index) => (typeof child === 'string' && !child.trim() ? null : child))?.filter(
11+
Boolean,
12+
) as ReactElement[]) ?? [];
13+
14+
const slides = items.map((child, index) =>
15+
typeof child === 'object' && child.type === 'video' ? (
16+
cloneElement(child, { controls: true, autoPlay: true })
17+
) : (
18+
<div className={styles.emblaSlide} key={index}>
19+
{child}
20+
</div>
21+
),
22+
);
23+
24+
const [emblaRef, emblaApi] = useEmblaCarousel({}, [
25+
Autoplay({
26+
delay: (x, api) => {
27+
return api.slideNodes().map((x) => (x.tagName === 'VIDEO' ? 10000 : 3000));
28+
},
29+
stopOnInteraction: true,
30+
}),
31+
]);
32+
33+
const scrollPrev = useCallback(() => {
34+
if (emblaApi) emblaApi.scrollPrev();
35+
}, [emblaApi]);
36+
37+
const scrollNext = useCallback(() => {
38+
if (emblaApi) emblaApi.scrollNext();
39+
}, [emblaApi]);
40+
41+
return (
42+
<div className={styles.carousel}>
43+
<div className={styles.embla}>
44+
<div className={styles.emblaViewport} ref={emblaRef}>
45+
<div className={styles.emblaContainer}>{slides}</div>
46+
</div>
47+
48+
<button className={styles.emblaPrev} onClick={scrollPrev}>
49+
Prev
50+
</button>
51+
<button className={styles.emblaNext} onClick={scrollNext}>
52+
Next
53+
</button>
54+
</div>
55+
56+
<div className={styles.thumbnails}>
57+
{items.map((child, index) => (
58+
<div className={styles.thumbnail} key={index} onClick={() => emblaApi?.scrollTo(index)}>
59+
{child}
60+
</div>
61+
))}
62+
</div>
63+
</div>
64+
);
65+
}

src/components/MDX/MDXComponents.module.css

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,88 @@
4141
.markdown a {
4242
@apply inline text-link dark:text-link-dark break-normal border-b border-link border-opacity-0 hover:border-opacity-100 duration-100 ease-in transition leading-normal;
4343
}
44+
45+
.embla {
46+
position: relative;
47+
}
48+
.emblaViewport {
49+
overflow: hidden;
50+
aspect-ratio: 16 / 9;
51+
}
52+
.emblaContainer {
53+
display: flex;
54+
height: 100%;
55+
}
56+
.emblaSlide {
57+
flex: 0 0 100%;
58+
min-width: 0;
59+
display: flex;
60+
flex-direction: row;
61+
justify-content: center;
62+
align-items: center;
63+
}
64+
.emblaPrev,
65+
.emblaNext {
66+
position: absolute;
67+
top: 50%;
68+
transform: translateY(-50%);
69+
width: 40px;
70+
height: 40px;
71+
display: flex;
72+
align-items: center;
73+
justify-content: center;
74+
cursor: pointer;
75+
font-size: 0;
76+
color: transparent;
77+
}
78+
79+
.emblaPrev:before,
80+
.emblaNext:before {
81+
content: '';
82+
display: inline-block;
83+
width: 20px;
84+
height: 20px;
85+
border: 2px solid black;
86+
border-radius: 3px;
87+
rotate: 45deg;
88+
}
89+
90+
.emblaPrev {
91+
left: 10px;
92+
}
93+
.emblaPrev:before {
94+
border-color: transparent transparent black black;
95+
}
96+
.emblaNext:before {
97+
border-color: black black transparent transparent;
98+
}
99+
100+
.emblaNext {
101+
right: 10px;
102+
}
103+
104+
.carousel {
105+
display: flex;
106+
flex-direction: column;
107+
gap: 12px;
108+
}
109+
110+
.thumbnails {
111+
display: flex;
112+
flex-direction: row;
113+
flex-wrap: wrap;
114+
justify-content: center;
115+
align-items: center;
116+
gap: 8px;
117+
}
118+
119+
.thumbnail {
120+
width: 100px;
121+
height: 60px;
122+
display: flex;
123+
flex-direction: row;
124+
justify-content: center;
125+
cursor: pointer;
126+
border-radius: 4px;
127+
overflow: hidden;
128+
}

0 commit comments

Comments
 (0)