Skip to content

Commit de62e3b

Browse files
author
Tanner Reits
committed
feat(segment): add playground & docs for segment view
1 parent 79c31eb commit de62e3b

File tree

12 files changed

+319
-1
lines changed

12 files changed

+319
-1
lines changed

docs/api/segment-content.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
title: "ion-segment-content"
3+
---
4+
5+
<head>
6+
<title>ion-segment-content: Display control element for swipeable segments</title>
7+
<meta name="description" content="ion-segment-contents are wrapper elements used to control the display of child elements when using swipeable segments." />
8+
</head>
9+
10+
import EncapsulationPill from '@components/page/api/EncapsulationPill';
11+
12+
<EncapsulationPill type="shadow" />
13+
14+
Segment content is a wrapper element used to control the display of child elements when using swipeable segments. Segment content elements are children of a single
15+
[segment view](./segment-view.md) instance that is linked to a [segment](./segment.md). See our [swipeable segments](./segment.md#swipeable-segments) documentation
16+
for more information on how to use `ion-segment-content`s.

docs/api/segment-view.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: "ion-segment-view"
3+
---
4+
5+
import Props from '@ionic-internal/component-api/v8.3.4-dev.11730395663.1a0f4848/segment-view/props.md';
6+
import Events from '@ionic-internal/component-api/v8.3.4-dev.11730395663.1a0f4848/segment-view/events.md';
7+
8+
<head>
9+
<title>ion-segment-view: Controller element for swipeable segments</title>
10+
<meta name="description" content="ion-segment-views are wrapper elements that link a group of segment contents to a segment" />
11+
</head>
12+
13+
import EncapsulationPill from '@components/page/api/EncapsulationPill';
14+
15+
<EncapsulationPill type="shadow" />
16+
17+
Segment view is a wrapper element that links a group of [segment contents](./segment-content.md) to a [segment](./segment.md) when using swipeable segments.
18+
See our [swipeable segments](./segment.md#swipeable-segments) documentation for more information on how to use `ion-segment-view`s.
19+
20+
## Properties
21+
22+
<Props />
23+
24+
## Events
25+
26+
<Events />

docs/api/segment.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ import Toolbar from '@site/static/usage/v8/toolbar/segments/index.md';
4949
<Toolbar />
5050

5151

52+
## Swipeable Segments
53+
54+
Each [segment button](./segment-button.md) can be associated with a [segment content](./segment-content.md) element that will be displayed
55+
when the segment is active. With this approach, each segment's content can be swiped or scrolled between and the segment will be updated
56+
to reflect the currently visible content.
57+
58+
If no initial `value` is assigned to the `ion-segment` when using swipeable segment, the segment will default to the value of the first segment button.
59+
60+
Segment buttons cannot be disabled when used with swipeable segments.
61+
62+
import Swipeable from '@site/static/usage/v8/segment/swipeable/index.md';
63+
64+
<Swipeable />
65+
5266
## Theming
5367

5468
### Colors

sidebars.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ module.exports = {
450450
type: 'category',
451451
label: 'Segment',
452452
collapsed: false,
453-
items: ['api/segment', 'api/segment-button'],
453+
items: ['api/segment', 'api/segment-button', 'api/segment-content', 'api/segment-view'],
454454
},
455455
{
456456
type: 'category',
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
```css
2+
ion-segment-view {
3+
height: 150px;
4+
}
5+
6+
ion-segment-content {
7+
display: flex;
8+
align-items: center;
9+
justify-content: center;
10+
}
11+
ion-segment-content:nth-of-type(1) {
12+
background: lightpink;
13+
}
14+
ion-segment-content:nth-of-type(2) {
15+
background: lightblue;
16+
}
17+
ion-segment-content:nth-of-type(3) {
18+
background: lightgreen;
19+
}
20+
```
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
```html
2+
<ion-segment>
3+
<ion-segment-button value="first" content-id="first">
4+
<ion-label>First</ion-label>
5+
</ion-segment-button>
6+
<ion-segment-button value="second" content-id="second">
7+
<ion-label>Second</ion-label>
8+
</ion-segment-button>
9+
<ion-segment-button value="third" content-id="third">
10+
<ion-label>Third</ion-label>
11+
</ion-segment-button>
12+
</ion-segment>
13+
<ion-segment-view>
14+
<ion-segment-content id="first">First</ion-segment-content>
15+
<ion-segment-content id="second">Second</ion-segment-content>
16+
<ion-segment-content id="third">Third</ion-segment-content>
17+
</ion-segment-view>
18+
```
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Segment - Swipeable</title>
7+
<link rel="stylesheet" href="../../common.css" />
8+
<script src="../../common.js"></script>
9+
<script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core@8/dist/ionic/ionic.esm.js"></script>
10+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core@8/css/ionic.bundle.css" />
11+
12+
<style>
13+
ion-segment-view {
14+
height: 168px;
15+
}
16+
17+
ion-segment-content {
18+
display: flex;
19+
align-items: center;
20+
justify-content: center;
21+
}
22+
ion-segment-content:nth-of-type(1) {
23+
background: lightpink;
24+
}
25+
ion-segment-content:nth-of-type(2) {
26+
background: lightblue;
27+
}
28+
ion-segment-content:nth-of-type(3) {
29+
background: lightgreen;
30+
}
31+
</style>
32+
</head>
33+
34+
<body>
35+
<ion-app>
36+
<ion-content>
37+
<ion-segment>
38+
<ion-segment-button value="first" content-id="first">
39+
<ion-label>First</ion-label>
40+
</ion-segment-button>
41+
<ion-segment-button value="second" content-id="second">
42+
<ion-label>Second</ion-label>
43+
</ion-segment-button>
44+
<ion-segment-button value="third" content-id="third">
45+
<ion-label>Third</ion-label>
46+
</ion-segment-button>
47+
</ion-segment>
48+
<ion-segment-view>
49+
<ion-segment-content id="first">First</ion-segment-content>
50+
<ion-segment-content id="second">Second</ion-segment-content>
51+
<ion-segment-content id="third">Third</ion-segment-content>
52+
</ion-segment-view>
53+
</ion-content>
54+
</ion-app>
55+
</body>
56+
</html>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import Playground from '@site/src/components/global/Playground';
2+
3+
import javascript from './javascript.md';
4+
import react_main_tsx from './react/react_tsx.md';
5+
import react_main_css from './react/react_css.md';
6+
import vue from './vue.md';
7+
import angular_html from './angular/angular_html.md';
8+
import angular_css from './angular/angular_css.md';
9+
10+
<Playground
11+
version="8"
12+
code={{
13+
javascript,
14+
react: {
15+
files: {
16+
'src/main.tsx': react_main_tsx,
17+
'src/main.css': react_main_css,
18+
},
19+
},
20+
vue,
21+
angular: {
22+
files: {
23+
'src/app/example.component.html': angular_html,
24+
'src/app/example.component.css': angular_css,
25+
},
26+
},
27+
}}
28+
src="usage/v8/segment/swipeable/demo.html"
29+
/>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
```html
2+
<ion-segment>
3+
<ion-segment-button value="first" content-id="first">
4+
<ion-label>First</ion-label>
5+
</ion-segment-button>
6+
<ion-segment-button value="second" content-id="second">
7+
<ion-label>Second</ion-label>
8+
</ion-segment-button>
9+
<ion-segment-button value="third" content-id="third">
10+
<ion-label>Third</ion-label>
11+
</ion-segment-button>
12+
</ion-segment>
13+
<ion-segment-view>
14+
<ion-segment-content id="first">First</ion-segment-content>
15+
<ion-segment-content id="second">Second</ion-segment-content>
16+
<ion-segment-content id="third">Third</ion-segment-content>
17+
</ion-segment-view>
18+
19+
<style>
20+
ion-segment-view {
21+
height: 150px;
22+
}
23+
24+
ion-segment-content {
25+
display: flex;
26+
align-items: center;
27+
justify-content: center;
28+
}
29+
ion-segment-content:nth-of-type(1) {
30+
background: lightpink;
31+
}
32+
ion-segment-content:nth-of-type(2) {
33+
background: lightblue;
34+
}
35+
ion-segment-content:nth-of-type(3) {
36+
background: lightgreen;
37+
}
38+
</style>
39+
```
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
```css
2+
ion-segment-view {
3+
height: 150px;
4+
}
5+
6+
ion-segment-content {
7+
display: flex;
8+
align-items: center;
9+
justify-content: center;
10+
}
11+
ion-segment-content:nth-of-type(1) {
12+
background: lightpink;
13+
}
14+
ion-segment-content:nth-of-type(2) {
15+
background: lightblue;
16+
}
17+
ion-segment-content:nth-of-type(3) {
18+
background: lightgreen;
19+
}
20+
```

0 commit comments

Comments
 (0)