mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 11:17:19 +08:00
fix(): update to Stencil One 🎉🎊
This commit is contained in:
@ -229,13 +229,12 @@ for (let i = 0; i < segments.length; i++) {
|
||||
|
||||
```tsx
|
||||
import React from 'react';
|
||||
import { IonSegment, IonSegmentButton, IonLabel, IonIcon, IonToolbar, IonContent } from '@ionic/react';
|
||||
|
||||
import { IonSegment, IonSegmentButton, IonLabel, IonIcon, IonToolbar } from '@ionic/react';
|
||||
|
||||
const Example: React.SFC<{}> = () => (
|
||||
<>
|
||||
export const SegmentExample: React.FunctionComponent = () => (
|
||||
<IonContent>
|
||||
{/*-- Default Segment --*/}
|
||||
<IonSegment onIonChange={(e) => console.log('Segment selected', e.detail.value)}>
|
||||
<IonSegment onIonChange={e => console.log('Segment selected', e.detail.value)}>
|
||||
<IonSegmentButton value="friends">
|
||||
<IonLabel>Friends</IonLabel>
|
||||
</IonSegmentButton>
|
||||
@ -245,7 +244,7 @@ const Example: React.SFC<{}> = () => (
|
||||
</IonSegment>
|
||||
|
||||
{/*-- Disabled Segment --*/}
|
||||
<IonSegment onIonChange={(e) => console.log('Segment selected', e.detail.value)} disabled>
|
||||
<IonSegment onIonChange={e => console.log('Segment selected', e.detail.value)} disabled>
|
||||
<IonSegmentButton value="sunny" checked>
|
||||
<IonLabel>Sunny</IonLabel>
|
||||
</IonSegmentButton>
|
||||
@ -255,7 +254,7 @@ const Example: React.SFC<{}> = () => (
|
||||
</IonSegment>
|
||||
|
||||
{/*-- Segment with anchors --*/}
|
||||
<IonSegment onIonChange={(e) => console.log('Segment selected', e.detail.value)}>
|
||||
<IonSegment onIonChange={e => console.log('Segment selected', e.detail.value)}>
|
||||
<IonSegmentButton value="dogs">
|
||||
<IonLabel>Dogs</IonLabel>
|
||||
</IonSegmentButton>
|
||||
@ -290,7 +289,7 @@ const Example: React.SFC<{}> = () => (
|
||||
</IonSegment>
|
||||
|
||||
{/*-- Segment with secondary color --*/}
|
||||
<IonSegment onIonChange={(e) => console.log('Segment selected', e.detail.value)} color="secondary">
|
||||
<IonSegment onIonChange={e => console.log('Segment selected', e.detail.value)} color="secondary">
|
||||
<IonSegmentButton value="standard">
|
||||
<IonLabel>Standard</IonLabel>
|
||||
</IonSegmentButton>
|
||||
@ -304,7 +303,7 @@ const Example: React.SFC<{}> = () => (
|
||||
|
||||
{/*-- Segment in a toolbar --*/}
|
||||
<IonToolbar>
|
||||
<IonSegment onIonChange={(e) => console.log('Segment selected', e.detail.value)}>
|
||||
<IonSegment onIonChange={e => console.log('Segment selected', e.detail.value)}>
|
||||
<IonSegmentButton value="camera">
|
||||
<IonIcon name="camera" />
|
||||
</IonSegmentButton>
|
||||
@ -315,7 +314,7 @@ const Example: React.SFC<{}> = () => (
|
||||
</IonToolbar>
|
||||
|
||||
{/*-- Segment with default selection --*/}
|
||||
<IonSegment onIonChange={(e) => console.log('Segment selected', e.detail.value)} value="javascript">
|
||||
<IonSegment onIonChange={e => console.log('Segment selected', e.detail.value)} value="javascript">
|
||||
<IonSegmentButton value="python">
|
||||
<IonLabel>Python</IonLabel>
|
||||
</IonSegmentButton>
|
||||
@ -323,10 +322,8 @@ const Example: React.SFC<{}> = () => (
|
||||
<IonLabel>Javascript</IonLabel>
|
||||
</IonSegmentButton>
|
||||
</IonSegment>
|
||||
</>
|
||||
</IonContent>
|
||||
);
|
||||
|
||||
export default Example;
|
||||
```
|
||||
|
||||
|
||||
|
@ -1,8 +1,12 @@
|
||||
import { Component, ComponentInterface, Element, Event, EventEmitter, Listen, Prop, Watch } from '@stencil/core';
|
||||
|
||||
import { Color, Mode, SegmentChangeEventDetail, StyleEventDetail } from '../../interface';
|
||||
import { getIonMode } from '../../global/ionic-global';
|
||||
import { Color, SegmentChangeEventDetail, StyleEventDetail } from '../../interface';
|
||||
import { createColorClasses } from '../../utils/theme';
|
||||
|
||||
/**
|
||||
* @virtualProp {"ios" | "md"} mode - The mode determines which platform styles to use.
|
||||
*/
|
||||
@Component({
|
||||
tag: 'ion-segment',
|
||||
styleUrls: {
|
||||
@ -22,11 +26,6 @@ export class Segment implements ComponentInterface {
|
||||
*/
|
||||
@Prop() color?: Color;
|
||||
|
||||
/**
|
||||
* The mode determines which platform styles to use.
|
||||
*/
|
||||
@Prop() mode!: Mode;
|
||||
|
||||
/**
|
||||
* If `true`, the user cannot interact with the segment.
|
||||
*/
|
||||
@ -96,10 +95,11 @@ export class Segment implements ComponentInterface {
|
||||
}
|
||||
|
||||
hostData() {
|
||||
const mode = getIonMode(this);
|
||||
return {
|
||||
class: {
|
||||
...createColorClasses(this.color),
|
||||
[`${this.mode}`]: true,
|
||||
[`${mode}`]: true,
|
||||
'segment-disabled': this.disabled,
|
||||
'segment-scrollable': this.scrollable
|
||||
}
|
||||
|
@ -8,8 +8,8 @@
|
||||
<link href="../../../../../css/ionic.bundle.css" rel="stylesheet">
|
||||
<link href="../../../../../scripts/testing/styles.css" rel="stylesheet">
|
||||
<script src="../../../../../scripts/testing/scripts.js"></script>
|
||||
<script src="../../../../../dist/ionic.js"></script>
|
||||
</head>
|
||||
<script nomodule src="../../../../../dist/ionic/ionic.js"></script>
|
||||
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script></head>
|
||||
|
||||
<body onload="listenForEvent()">
|
||||
<ion-app>
|
||||
|
@ -8,8 +8,8 @@
|
||||
<link href="../../../../../css/ionic.bundle.css" rel="stylesheet">
|
||||
<link href="../../../../../scripts/testing/styles.css" rel="stylesheet">
|
||||
<script src="../../../../../scripts/testing/scripts.js"></script>
|
||||
<script src="../../../../../dist/ionic.js"></script>
|
||||
</head>
|
||||
<script nomodule src="../../../../../dist/ionic/ionic.js"></script>
|
||||
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script></head>
|
||||
|
||||
<body>
|
||||
<ion-app>
|
||||
|
@ -8,8 +8,8 @@
|
||||
<link href="../../../../../css/ionic.bundle.css" rel="stylesheet">
|
||||
<link href="../../../../../scripts/testing/styles.css" rel="stylesheet">
|
||||
<script src="../../../../../scripts/testing/scripts.js"></script>
|
||||
<script src="../../../../../dist/ionic.js"></script>
|
||||
</head>
|
||||
<script nomodule src="../../../../../dist/ionic/ionic.js"></script>
|
||||
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script></head>
|
||||
|
||||
<body>
|
||||
<ion-app>
|
||||
|
@ -8,8 +8,8 @@
|
||||
<link href="../../../../../css/ionic.bundle.css" rel="stylesheet">
|
||||
<link href="../../../../../scripts/testing/styles.css" rel="stylesheet">
|
||||
<script src="../../../../../scripts/testing/scripts.js"></script>
|
||||
<script src="../../../../../dist/ionic.js"></script>
|
||||
</head>
|
||||
<script nomodule src="../../../../../dist/ionic/ionic.js"></script>
|
||||
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script></head>
|
||||
|
||||
<body onLoad="setLayout()">
|
||||
<ion-app>
|
||||
|
@ -8,8 +8,8 @@
|
||||
<link href="../../../../../css/ionic.bundle.css" rel="stylesheet">
|
||||
<link href="../../../../../scripts/testing/styles.css" rel="stylesheet">
|
||||
<script src="../../../../../scripts/testing/scripts.js"></script>
|
||||
<script src="../../../../../dist/ionic.js"></script>
|
||||
</head>
|
||||
<script nomodule src="../../../../../dist/ionic/ionic.js"></script>
|
||||
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script></head>
|
||||
|
||||
<body onLoad="setLayout()">
|
||||
<ion-app>
|
||||
|
@ -8,8 +8,8 @@
|
||||
<link href="../../../../../css/core.css" rel="stylesheet">
|
||||
<link href="../../../../../scripts/testing/styles.css" rel="stylesheet">
|
||||
<script src="../../../../../scripts/testing/scripts.js"></script>
|
||||
<script src="../../../../../dist/ionic.js"></script>
|
||||
</head>
|
||||
<script nomodule src="../../../../../dist/ionic/ionic.js"></script>
|
||||
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script></head>
|
||||
|
||||
<body>
|
||||
<ion-toolbar>
|
||||
|
@ -8,8 +8,8 @@
|
||||
<link href="../../../../../css/ionic.bundle.css" rel="stylesheet">
|
||||
<link href="../../../../../scripts/testing/styles.css" rel="stylesheet">
|
||||
<script src="../../../../../scripts/testing/scripts.js"></script>
|
||||
<script src="../../../../../dist/ionic.js"></script>
|
||||
</head>
|
||||
<script nomodule src="../../../../../dist/ionic/ionic.js"></script>
|
||||
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script></head>
|
||||
|
||||
<body>
|
||||
<ion-app>
|
||||
|
@ -1,12 +1,11 @@
|
||||
```tsx
|
||||
import React from 'react';
|
||||
import { IonSegment, IonSegmentButton, IonLabel, IonIcon, IonToolbar, IonContent } from '@ionic/react';
|
||||
|
||||
import { IonSegment, IonSegmentButton, IonLabel, IonIcon, IonToolbar } from '@ionic/react';
|
||||
|
||||
const Example: React.SFC<{}> = () => (
|
||||
<>
|
||||
export const SegmentExample: React.FunctionComponent = () => (
|
||||
<IonContent>
|
||||
{/*-- Default Segment --*/}
|
||||
<IonSegment onIonChange={(e) => console.log('Segment selected', e.detail.value)}>
|
||||
<IonSegment onIonChange={e => console.log('Segment selected', e.detail.value)}>
|
||||
<IonSegmentButton value="friends">
|
||||
<IonLabel>Friends</IonLabel>
|
||||
</IonSegmentButton>
|
||||
@ -16,7 +15,7 @@ const Example: React.SFC<{}> = () => (
|
||||
</IonSegment>
|
||||
|
||||
{/*-- Disabled Segment --*/}
|
||||
<IonSegment onIonChange={(e) => console.log('Segment selected', e.detail.value)} disabled>
|
||||
<IonSegment onIonChange={e => console.log('Segment selected', e.detail.value)} disabled>
|
||||
<IonSegmentButton value="sunny" checked>
|
||||
<IonLabel>Sunny</IonLabel>
|
||||
</IonSegmentButton>
|
||||
@ -26,7 +25,7 @@ const Example: React.SFC<{}> = () => (
|
||||
</IonSegment>
|
||||
|
||||
{/*-- Segment with anchors --*/}
|
||||
<IonSegment onIonChange={(e) => console.log('Segment selected', e.detail.value)}>
|
||||
<IonSegment onIonChange={e => console.log('Segment selected', e.detail.value)}>
|
||||
<IonSegmentButton value="dogs">
|
||||
<IonLabel>Dogs</IonLabel>
|
||||
</IonSegmentButton>
|
||||
@ -61,7 +60,7 @@ const Example: React.SFC<{}> = () => (
|
||||
</IonSegment>
|
||||
|
||||
{/*-- Segment with secondary color --*/}
|
||||
<IonSegment onIonChange={(e) => console.log('Segment selected', e.detail.value)} color="secondary">
|
||||
<IonSegment onIonChange={e => console.log('Segment selected', e.detail.value)} color="secondary">
|
||||
<IonSegmentButton value="standard">
|
||||
<IonLabel>Standard</IonLabel>
|
||||
</IonSegmentButton>
|
||||
@ -75,7 +74,7 @@ const Example: React.SFC<{}> = () => (
|
||||
|
||||
{/*-- Segment in a toolbar --*/}
|
||||
<IonToolbar>
|
||||
<IonSegment onIonChange={(e) => console.log('Segment selected', e.detail.value)}>
|
||||
<IonSegment onIonChange={e => console.log('Segment selected', e.detail.value)}>
|
||||
<IonSegmentButton value="camera">
|
||||
<IonIcon name="camera" />
|
||||
</IonSegmentButton>
|
||||
@ -86,7 +85,7 @@ const Example: React.SFC<{}> = () => (
|
||||
</IonToolbar>
|
||||
|
||||
{/*-- Segment with default selection --*/}
|
||||
<IonSegment onIonChange={(e) => console.log('Segment selected', e.detail.value)} value="javascript">
|
||||
<IonSegment onIonChange={e => console.log('Segment selected', e.detail.value)} value="javascript">
|
||||
<IonSegmentButton value="python">
|
||||
<IonLabel>Python</IonLabel>
|
||||
</IonSegmentButton>
|
||||
@ -94,8 +93,6 @@ const Example: React.SFC<{}> = () => (
|
||||
<IonLabel>Javascript</IonLabel>
|
||||
</IonSegmentButton>
|
||||
</IonSegment>
|
||||
</>
|
||||
</IonContent>
|
||||
);
|
||||
|
||||
export default Example;
|
||||
```
|
||||
```
|
Reference in New Issue
Block a user