Skip to content

Commit b07caa9

Browse files
authored
Merge pull request #35 from vadimkorr/feature/#33_Change-pages-programmatically
Feature/#33 Change pages programmatically
2 parents 121ca24 + cdc03da commit b07caa9

File tree

14 files changed

+483
-37
lines changed

14 files changed

+483
-37
lines changed

.npmignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ storybook-static
88
# dist
99
scripts
1010

11-
.test.js
11+
src/**/*.test.js
12+
13+
DEPLOYMENT.md

.storybook/preview.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import './styles.css'
12

23
export const parameters = {
34
actions: { argTypesRegex: "^on[A-Z].*" },

.storybook/styles.css

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
.sb-container {
2+
padding: 10px;
3+
border-radius: 5px;
4+
background-color: #d2d2d2;
5+
}
6+
7+
span.sb-title {
8+
color: #3e3e3e;
9+
display: block;
10+
margin: 5px;
11+
font-size: 16px;
12+
font-family: Arial, Helvetica, sans-serif;
13+
}
14+
15+
.sb-divider {
16+
max-width: 100%;
17+
border-bottom: solid 3px #ffffff;
18+
margin: 5px;
19+
box-sizing: border-box;
20+
}
21+
22+
.sb-button {
23+
width: 150px;
24+
height: 35px;
25+
margin: 5px;
26+
padding: 0px 10px;
27+
border-radius: 5px;
28+
background-color: #009800;
29+
border: none;
30+
color: white;
31+
text-decoration: none;
32+
font-size: 14px;
33+
cursor: pointer;
34+
}
35+
36+
.sb-input[type=text],
37+
.sb-input[type=number] {
38+
width: 150px;
39+
height: 35px;
40+
margin: 5px;
41+
padding: 0px 10px;
42+
border-radius: 5px;
43+
display: inline-block;
44+
border: 1px solid #9f9f9f;
45+
outline: none;
46+
box-sizing: border-box;
47+
}

DEPLOYMENT.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# How to publish new feature:
2+
3+
1. Update unit tests
4+
2. Update storybook
5+
6+
3. Update version in `package.json`
7+
8+
4. Update docs in `README.md`
9+
5. Update docs in `src/docs`
10+
6. `yarn build:docs`
11+
12+
7. `npm publish`
13+
8. Merge feature branch
14+
9. Create release in GitHub

README.md

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,85 @@ Slot props:
137137
</div>
138138
<!-- -->
139139
</Carousel>
140-
```
140+
```
141+
142+
## Methods
143+
144+
### `goTo`
145+
Navigates to a page by index
146+
147+
Arguments:
148+
149+
| Argument | Type | Default | Description |
150+
|--------------------|-------------|---------|---------------------------------------|
151+
| `pageIndex` | `number` | | Page number |
152+
| `options.animated` | `boolean` | `true` | Should it be animated or not |
153+
154+
```jsx
155+
<script>
156+
// ...
157+
let carousel;
158+
function goToStartPage() {
159+
carousel.goTo(0, { animated: false })
160+
}
161+
</script>
162+
163+
<Carousel
164+
bind:this={carousel}
165+
>
166+
<!-- -->
167+
</Carousel>
168+
<button class="button" on:click={goToStartPage}>Go</button>
169+
```
170+
171+
### `goToPrev`
172+
Navigates to the previous page
173+
174+
Arguments:
175+
176+
| Argument | Type | Default | Description |
177+
|--------------------|-------------|---------|---------------------------------------|
178+
| `options.animated` | `boolean` | `true` | Should it be animated or not |
179+
180+
```jsx
181+
<script>
182+
// ...
183+
let carousel;
184+
function goToPrevPage() {
185+
carousel.goToPrev({ animated: false })
186+
}
187+
</script>
188+
189+
<Carousel
190+
bind:this={carousel}
191+
>
192+
<!-- -->
193+
</Carousel>
194+
<button class="button" on:click={goToPrevPage}>Go</button>
195+
```
196+
197+
### `goToNext`
198+
Navigates to the next page
199+
200+
Arguments:
201+
202+
| Argument | Type | Default | Description |
203+
|--------------------|-------------|---------|---------------------------------------|
204+
| `options.animated` | `boolean` | `true` | Should it be animated or not |
205+
206+
```jsx
207+
<script>
208+
// ...
209+
let carousel;
210+
function goToNextPage() {
211+
carousel.goToNext({ animated: false })
212+
}
213+
</script>
214+
215+
<Carousel
216+
bind:this={carousel}
217+
>
218+
<!-- -->
219+
</Carousel>
220+
<button class="button" on:click={goToNextPage}>Go</button>
221+
```

docs/index.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)