-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat(segment): add playground & docs for segment view #3875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
tanner-reits
merged 4 commits into
feature-8.4
from
tr/ROU-11249-segment-view-playground
Nov 4, 2024
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
title: "ion-segment-content" | ||
--- | ||
|
||
import Props from '@ionic-internal/component-api/v8/segment-content/props.md'; | ||
import Events from '@ionic-internal/component-api/v8/segment-content/events.md'; | ||
import Methods from '@ionic-internal/component-api/v8/segment-content/methods.md'; | ||
import Parts from '@ionic-internal/component-api/v8/segment-content/parts.md'; | ||
import CustomProps from '@ionic-internal/component-api/v8/segment-content/custom-props.mdx'; | ||
import Slots from '@ionic-internal/component-api/v8/segment-content/slots.md'; | ||
|
||
<head> | ||
tanner-reits marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<title>ion-segment-content: Display control element for swipeable segments</title> | ||
<meta name="description" content="ion-segment-contents are wrapper elements used to control the display of child elements when using swipeable segments." /> | ||
</head> | ||
|
||
import EncapsulationPill from '@components/page/api/EncapsulationPill'; | ||
|
||
<EncapsulationPill type="shadow" /> | ||
|
||
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 | ||
[segment view](./segment-view.md) instance that is linked to a [segment](./segment.md). See our [swipeable segments](./segment.md#swipeable-segments) documentation | ||
for more information on how to use segment contents. | ||
|
||
## Usage | ||
|
||
Each `ion-segment-content` needs a unique `id` attribute. This will be used to link the segment content to a segment button via the button's | ||
[contentId property](./segment-button.md#properties). | ||
|
||
<!-- Reuse swipeable segments playground --> | ||
|
||
import Swipeable from '@site/static/usage/v8/segment/swipeable/index.md'; | ||
|
||
<Swipeable /> | ||
|
||
## Properties | ||
<Props /> | ||
|
||
## Events | ||
<Events /> | ||
|
||
## Methods | ||
<Methods /> | ||
|
||
## CSS Shadow Parts | ||
<Parts /> | ||
|
||
## CSS Custom Properties | ||
<CustomProps /> | ||
|
||
## Slots | ||
<Slots /> |
tanner-reits marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
title: "ion-segment-view" | ||
--- | ||
|
||
import Props from '@ionic-internal/component-api/v8/segment-view/props.md'; | ||
import Events from '@ionic-internal/component-api/v8/segment-view/events.md'; | ||
import Methods from '@ionic-internal/component-api/v8/segment-view/methods.md'; | ||
import Parts from '@ionic-internal/component-api/v8/segment-view/parts.md'; | ||
import CustomProps from '@ionic-internal/component-api/v8/segment-view/custom-props.mdx'; | ||
import Slots from '@ionic-internal/component-api/v8/segment-view/slots.md'; | ||
|
||
<head> | ||
<title>ion-segment-view: Controller element for swipeable segments</title> | ||
<meta name="description" content="ion-segment-views are wrapper elements that link a group of segment contents to a segment" /> | ||
</head> | ||
|
||
import EncapsulationPill from '@components/page/api/EncapsulationPill'; | ||
|
||
<EncapsulationPill type="shadow" /> | ||
|
||
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. | ||
See our [swipeable segments](./segment.md#swipeable-segments) documentation for more information on how to use segment views. | ||
|
||
## Properties | ||
<Props /> | ||
|
||
## Events | ||
<Events /> | ||
|
||
## Methods | ||
<Methods /> | ||
|
||
## CSS Shadow Parts | ||
<Parts /> | ||
|
||
## CSS Custom Properties | ||
<CustomProps /> | ||
|
||
## Slots | ||
<Slots /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
```css | ||
ion-segment-view { | ||
height: 150px; | ||
} | ||
|
||
ion-segment-content { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
ion-segment-content:nth-of-type(1) { | ||
background: lightpink; | ||
} | ||
ion-segment-content:nth-of-type(2) { | ||
background: lightblue; | ||
} | ||
ion-segment-content:nth-of-type(3) { | ||
background: lightgreen; | ||
} | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
```html | ||
<ion-segment> | ||
<ion-segment-button value="first" content-id="first"> | ||
<ion-label>First</ion-label> | ||
</ion-segment-button> | ||
<ion-segment-button value="second" content-id="second"> | ||
<ion-label>Second</ion-label> | ||
</ion-segment-button> | ||
<ion-segment-button value="third" content-id="third"> | ||
<ion-label>Third</ion-label> | ||
</ion-segment-button> | ||
</ion-segment> | ||
<ion-segment-view> | ||
<ion-segment-content id="first">First</ion-segment-content> | ||
<ion-segment-content id="second">Second</ion-segment-content> | ||
<ion-segment-content id="third">Third</ion-segment-content> | ||
</ion-segment-view> | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Segment - Swipeable</title> | ||
<link rel="stylesheet" href="../../common.css" /> | ||
<script src="../../common.js"></script> | ||
<script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core@8/dist/ionic/ionic.esm.js"></script> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core@8/css/ionic.bundle.css" /> | ||
|
||
<style> | ||
ion-segment-view { | ||
height: 168px; | ||
} | ||
|
||
ion-segment-content { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
ion-segment-content:nth-of-type(1) { | ||
background: lightpink; | ||
} | ||
ion-segment-content:nth-of-type(2) { | ||
background: lightblue; | ||
} | ||
ion-segment-content:nth-of-type(3) { | ||
background: lightgreen; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<ion-app> | ||
<ion-content> | ||
<ion-segment> | ||
<ion-segment-button value="first" content-id="first"> | ||
<ion-label>First</ion-label> | ||
</ion-segment-button> | ||
<ion-segment-button value="second" content-id="second"> | ||
<ion-label>Second</ion-label> | ||
</ion-segment-button> | ||
<ion-segment-button value="third" content-id="third"> | ||
<ion-label>Third</ion-label> | ||
</ion-segment-button> | ||
</ion-segment> | ||
<ion-segment-view> | ||
<ion-segment-content id="first">First</ion-segment-content> | ||
<ion-segment-content id="second">Second</ion-segment-content> | ||
<ion-segment-content id="third">Third</ion-segment-content> | ||
</ion-segment-view> | ||
</ion-content> | ||
</ion-app> | ||
</body> | ||
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import Playground from '@site/src/components/global/Playground'; | ||
|
||
import javascript from './javascript.md'; | ||
import react_main_tsx from './react/react_tsx.md'; | ||
import react_main_css from './react/react_css.md'; | ||
import vue from './vue.md'; | ||
import angular_html from './angular/angular_html.md'; | ||
import angular_css from './angular/angular_css.md'; | ||
|
||
<Playground | ||
version="8" | ||
code={{ | ||
javascript, | ||
react: { | ||
files: { | ||
'src/main.tsx': react_main_tsx, | ||
'src/main.css': react_main_css, | ||
}, | ||
}, | ||
vue, | ||
angular: { | ||
files: { | ||
'src/app/example.component.html': angular_html, | ||
'src/app/example.component.css': angular_css, | ||
}, | ||
}, | ||
}} | ||
src="usage/v8/segment/swipeable/demo.html" | ||
/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
```html | ||
<ion-segment> | ||
<ion-segment-button value="first" content-id="first"> | ||
<ion-label>First</ion-label> | ||
</ion-segment-button> | ||
<ion-segment-button value="second" content-id="second"> | ||
<ion-label>Second</ion-label> | ||
</ion-segment-button> | ||
<ion-segment-button value="third" content-id="third"> | ||
<ion-label>Third</ion-label> | ||
</ion-segment-button> | ||
</ion-segment> | ||
<ion-segment-view> | ||
<ion-segment-content id="first">First</ion-segment-content> | ||
<ion-segment-content id="second">Second</ion-segment-content> | ||
<ion-segment-content id="third">Third</ion-segment-content> | ||
</ion-segment-view> | ||
|
||
<style> | ||
ion-segment-view { | ||
height: 150px; | ||
} | ||
|
||
ion-segment-content { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
ion-segment-content:nth-of-type(1) { | ||
background: lightpink; | ||
} | ||
ion-segment-content:nth-of-type(2) { | ||
background: lightblue; | ||
} | ||
ion-segment-content:nth-of-type(3) { | ||
background: lightgreen; | ||
} | ||
</style> | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
```css | ||
ion-segment-view { | ||
height: 150px; | ||
} | ||
|
||
ion-segment-content { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
ion-segment-content:nth-of-type(1) { | ||
background: lightpink; | ||
} | ||
ion-segment-content:nth-of-type(2) { | ||
background: lightblue; | ||
} | ||
ion-segment-content:nth-of-type(3) { | ||
background: lightgreen; | ||
} | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
```tsx | ||
import React from 'react'; | ||
import { IonLabel, IonSegment, IonSegmentButton, IonSegmentContent, IonSegmentView } from '@ionic/react'; | ||
|
||
import './main.css'; | ||
|
||
function Example() { | ||
return ( | ||
<> | ||
<IonSegment value="first"> | ||
<IonSegmentButton value="first" contentId="first"> | ||
<IonLabel>First</IonLabel> | ||
</IonSegmentButton> | ||
<IonSegmentButton value="second" contentId="second"> | ||
<IonLabel>Second</IonLabel> | ||
</IonSegmentButton> | ||
<IonSegmentButton value="third" contentId="third"> | ||
<IonLabel>Third</IonLabel> | ||
</IonSegmentButton> | ||
</IonSegment> | ||
<IonSegmentView> | ||
<IonSegmentContent id="first">First</IonSegmentContent> | ||
<IonSegmentContent id="second">Second</IonSegmentContent> | ||
<IonSegmentContent id="third">Third</IonSegmentContent> | ||
</IonSegmentView> | ||
</> | ||
); | ||
} | ||
export default Example; | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
```html | ||
<template> | ||
<ion-segment> | ||
<ion-segment-button value="first" content-id="first"> | ||
<ion-label>First</ion-label> | ||
</ion-segment-button> | ||
<ion-segment-button value="second" content-id="second"> | ||
<ion-label>Second</ion-label> | ||
</ion-segment-button> | ||
<ion-segment-button value="third" content-id="third"> | ||
<ion-label>Third</ion-label> | ||
</ion-segment-button> | ||
</ion-segment> | ||
<ion-segment-view> | ||
<ion-segment-content id="first">First</ion-segment-content> | ||
<ion-segment-content id="second">Second</ion-segment-content> | ||
<ion-segment-content id="third">Third</ion-segment-content> | ||
</ion-segment-view> | ||
</template> | ||
|
||
<style> | ||
ion-segment-view { | ||
height: 150px; | ||
} | ||
|
||
ion-segment-content { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
ion-segment-content:nth-of-type(1) { | ||
background: lightpink; | ||
} | ||
ion-segment-content:nth-of-type(2) { | ||
background: lightblue; | ||
} | ||
ion-segment-content:nth-of-type(3) { | ||
background: lightgreen; | ||
} | ||
</style> | ||
|
||
<script lang="ts"> | ||
import { IonLabel, IonSegment, IonSegmentButton, IonSegmentContent, IonSegmentView } from '@ionic/vue'; | ||
import { defineComponent } from 'vue'; | ||
|
||
export default defineComponent({ | ||
components: { IonLabel, IonSegment, IonSegmentButton, IonSegmentContent, IonSegmentView }, | ||
}); | ||
</script> | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.