Skip to content

Commit 5090482

Browse files
authored
Show docs showcase on mobile and use carousel for showcase (#1316)
1 parent 67409c0 commit 5090482

File tree

4 files changed

+50
-18
lines changed

4 files changed

+50
-18
lines changed

src/components/button/ButtonTypes.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ export const DEFAULT_PROPS = {
161161
* @extends: TouchableOpacity
162162
* @extendsLink: docs/TouchableOpacity
163163
* @modifiers: margin, background
164-
* @gif: https://media.giphy.com/media/xULW8j5WzsuPytqklq/giphy.gif
164+
* @image: https://user-images.githubusercontent.com/1780255/119218638-173e3b00-baea-11eb-8e66-f5a23714871c.png, https://user-images.githubusercontent.com/1780255/119218639-173e3b00-baea-11eb-8b75-b6dde4e922c8.png, https://user-images.githubusercontent.com/1780255/119218636-16a5a480-baea-11eb-8501-33eebfe1f3e2.png, https://user-images.githubusercontent.com/1780255/119218637-16a5a480-baea-11eb-99d0-3620f2160ec5.png, https://user-images.githubusercontent.com/1780255/119218634-160d0e00-baea-11eb-8538-e78005cb3fa5.png, https://user-images.githubusercontent.com/1780255/119221003-d9471400-baf5-11eb-9066-0aabbe8d9022.png
165+
* @gif: https://user-images.githubusercontent.com/1780255/119218630-11e0f080-baea-11eb-8e32-4470195cc42f.gif
165166
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/ButtonsScreen.tsx
166167
*/
167168
// @ts-ignore

uilib-docs/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "uilib-docs",
33
"description": "uilib docs template",
4-
"version": "1.0.15",
4+
"version": "1.0.16",
55
"author": "Ethan Sharabi <[email protected]>",
66
"main": "index.js",
77
"dependencies": {
@@ -26,7 +26,9 @@
2626
"prop-types": "^15.7.2",
2727
"react": "^16.8.4",
2828
"react-dom": "^16.8.4",
29-
"react-helmet": "^6.0.0"
29+
"react-helmet": "^6.0.0",
30+
"react-slick": "^0.28.1",
31+
"slick-carousel": "^1.8.1"
3032
},
3133
"devDependencies": {
3234
"prettier": "^1.16.4"

uilib-docs/src/templates/component.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import PropTypes from 'prop-types';
33
import _ from 'lodash';
44
import Link from 'gatsby-link';
55
import classnames from 'classnames';
6+
import Slider from 'react-slick';
7+
import 'slick-carousel/slick/slick.css';
8+
import 'slick-carousel/slick/slick-theme.css';
69

710
import './components.scss';
811
import importantIcon from '../images/important.svg';
@@ -102,7 +105,9 @@ export default class ComponentTemplate extends Component {
102105

103106
<ul>
104107
{_.map(extendLinks, link => (
105-
<li className="link" key={link}>{link}</li>
108+
<li className="link" key={link}>
109+
{link}
110+
</li>
106111
))}
107112
</ul>
108113

@@ -147,17 +152,22 @@ export default class ComponentTemplate extends Component {
147152
}
148153
}
149154

150-
renderVisuals(componentInfo) {
155+
renderVisuals(componentInfo, forMobile) {
151156
const gifs = componentInfo.gif ? componentInfo.gif.split(',') : [];
152157
const imgs = componentInfo.image ? componentInfo.image.split(',') : [];
153-
const visuals = [...gifs, ...imgs];
158+
const visuals = [...imgs, ...gifs];
154159

155160
if (!_.isEmpty(visuals)) {
156161
return (
157-
<div className="visuals">
158-
{_.map(visuals, (image, i) => {
159-
return <img key={i} alt={''} src={image} />;
160-
})}
162+
<div className={classnames('visuals', {mobile: forMobile})}>
163+
{forMobile ? <h3>Showcase</h3> : <div className="list-header">Showcase</div>}
164+
<div className="carousel">
165+
<Slider arrows dots infinite autoplay>
166+
{_.map(visuals, (image, i) => {
167+
return <img key={i} alt={''} src={image} />;
168+
})}
169+
</Slider>
170+
</div>
161171
</div>
162172
);
163173
}
@@ -166,8 +176,8 @@ export default class ComponentTemplate extends Component {
166176
renderSidebar(componentInfo, componentProps) {
167177
return (
168178
<div className="sidebar">
169-
<TableOfContent props={componentProps} />
170179
{this.renderVisuals(componentInfo)}
180+
<TableOfContent props={componentProps} />
171181
</div>
172182
);
173183
}
@@ -215,6 +225,7 @@ export default class ComponentTemplate extends Component {
215225

216226
{this.renderNotes(componentInfo)}
217227

228+
{this.renderVisuals(componentInfo, true)}
218229
<ComponentAPI props={componentProps} href={href} />
219230
</div>
220231
</div>

uilib-docs/src/templates/components.scss

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,33 @@ $tabletOfContentWidth: 20vw;
8787
.visuals {
8888
display: flex;
8989
flex-direction: column;
90-
padding-left: 20px;
91-
margin-top: 20px;
90+
box-sizing: content-box;
91+
margin: 20px;
9292

93-
img {
94-
width: 70%;
93+
&.mobile {
94+
@include desktop {
95+
display: none;
96+
}
97+
}
98+
99+
.carousel {
100+
margin-top: 40px;
95101
border-radius: 4px;
96-
border: 6px solid $dark60;
102+
border: 4px solid $dark60;
97103
box-shadow: 2px 2px 10px rgba($dark10, 0.3);
98-
margin-bottom: 20px;
104+
105+
.slick-track {
106+
display: flex;
107+
}
108+
109+
.slick-slide {
110+
align-self: center;
111+
}
112+
113+
.slick-dots {
114+
top: -35px;
115+
bottom: unset;
116+
}
99117
}
100118
}
101119
}
@@ -211,6 +229,7 @@ $tabletOfContentWidth: 20vw;
211229
.docs-page {
212230
@include component-api();
213231
@include notes();
232+
@include visuals();
214233

215234
display: flex;
216235
flex-direction: row;
@@ -244,7 +263,6 @@ $tabletOfContentWidth: 20vw;
244263
overflow-y: auto;
245264

246265
@include tabletOfContent();
247-
@include visuals();
248266

249267
@include desktop {
250268
display: initial;

0 commit comments

Comments
 (0)