React Banner (バナー) の概要
Ignite UI for React Banner コンポーネントは、スナックバーより長い時間の表示でダイアログより控えめのメッセージを簡単に表示できます。また、メッセージのコンテキストに基づいて実行するアクションを示すこともできます。
Ignite UI for React Banner の例
EXAMPLE
TSX
BannerSample1.css
index.css
import React , { useEffect, useRef } from 'react' ;
import ReactDOM from 'react-dom/client' ;
import {
IgrBanner,
IgrBannerModule,
IgrCard,
IgrCardModule,
IgrIcon,
IgrIconModule,
IgrNavbar,
IgrNavbarModule,
} from "@infragistics/igniteui-react" ;
import 'igniteui-webcomponents/themes/light/bootstrap.css' ;
import './BannerSample1.css' ;
import './index.css' ;
import { registerIconFromText } from 'igniteui-webcomponents' ;
IgrBannerModule.register();
IgrNavbarModule.register();
IgrIconModule.register();
IgrCardModule.register();
const refreshIcon =
'<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"/></svg>' ;
export default function BannerSample1() {
const bannerRef = useRef<IgrBanner > (null );
useEffect(() => {
registerIconFromText('refresh' , refreshIcon);
bannerRef.current.open = true ;
}, [])
return (
<div className ="gallery__wrapper" >
<div className ="gallery__content" >
<IgrNavbar >
<h1 key ="header" > Gallery</h1 >
<IgrIcon key ="icon" name ="refresh" slot ="end" onClick ={() => bannerRef.current.show()}></IgrIcon >
</IgrNavbar >
<IgrBanner ref ={bannerRef} className ="offline-banner" >
<span key ="message" > You are currently offline.</span >
</IgrBanner >
<IgrCard className ="gallery__item" elevated >
<div key ="img-forest" >
<img src ="https://www.infragistics.com/angular-demos-lob/assets/images/card/media/the_red_ice_forest.jpg" />
</div >
</IgrCard >
<IgrCard className ="gallery__item" elevated >
<div key ="img-yosemite" >
<img src ="https://www.infragistics.com/angular-demos-lob/assets/images/card/media/yosemite.jpg" />
</div >
</IgrCard >
</div >
</div >
);
}
const root = ReactDOM.createRoot (document.getElementById('root' ));
root.render (<BannerSample1 /> );
tsx コピー .offline-banner {
border-bottom : 1px solid rgba (0 , 0 , 0 , .12 );
}
.gallery__wrapper {
max-width : 400px ;
padding-top : 24px ;
margin : 0 auto;
}
.gallery__content {
display : flex;
flex-flow : column;
max-height : 430px ;
overflow : hidden;
box-shadow : 0 1px 3px 0 rgba (0 ,0 ,0 ,.2 ), 0 1px 1px 0 rgba (0 ,0 ,0 ,.14 ), 0 2px 1px -1px rgba (0 ,0 ,0 ,.12 );
}
.gallery__item {
margin : 8px 16px ;
overflow : visible;
border-radius : 0 ;
& div {
display : flex;
justify-content : center;
}
}
img {
max-width : 100% ;
}
css コピー
このサンプルが気に入りましたか? 完全な Ignite UI for Reactツールキットにアクセスして、すばやく独自のアプリの作成を開始します。無料でダウンロードできます。
使用方法
まず、次のコマンドを実行して、対応する Ignite UI for React npm パッケージをインストールする必要があります:
npm install igniteui-react
cmd
次に、以下のように、IgrBanner
とそれに必要な CSS をインポートし、そのモジュールを登録する必要があります:
import { IgrBannerModule, IgrBanner } from 'igniteui-react' ;
import 'igniteui-webcomponents/themes/light/bootstrap.css' ;
IgrBannerModule.register();
tsx
Ignite UI for React の完全な概要については、作業の開始 トピックを参照してください。
Banner の表示
Banner コンポーネントを表示するには、ボタン クリックで show
メソッドを呼び出します。バナーは、要素がページ テンプレートに挿入された場所にその他すべてのコンテンツを移動して表示されます。通常、閉じるためのユーザー操作をほとんど必要としない非侵入型コンテンツを表示します。
<IgrButton clicked ={() => bannerRef.current.show()}>
<span > Show Banner</span >
</IgrButton >
<IgrBanner ref ={bannerRef} >
<span key ="message" > You are currently offline.</span >
</IgrBanner >
tsx
IgrBanner には、バナーを閉じるデフォルトの OK アクション ボタンが含まれています。
例
IgrBanner
コンポーネントは、マテリアル デザイン バナー ガイドラインにできるかぎり準拠しながらコンテンツをテンプレート化します。
バナー メッセージの変更
IgrBanner
タグに渡されるコンテンツを変更することによりバナーに表示されるメッセージを設定できます。指定したバナー領域にテキストが表示され、表示時にバナーはデフォルト テンプレートを使用します。以下は、サンプル バナーのコンテンツを変更してより多くの情報を提供します。
<IgrBanner ref ={bannerRef} >
<span key ="message" > You have lost connection to the internet. This app is offline.</span >
</IgrBanner >
tsx
アイコンの追加
バナーの prefix
スロットを使用して、IgrIcon
をバナーに表示できます。Icon は常にバナー メッセージの最初に配置されます。
複数の IgrIcon 要素が挿入される場合、バナーはそれらすべてを最初に配置しようとします。IgrIcon は 1 つのみ、直接渡すことに注意してください。
IgrIcon
をバナーに渡すには、prefix
スロットを使用します。
<IgrBanner ref ={bannerRef} >
<IgrIcon key ="icon" slot ="prefix" name ="signal_wifi_off" > </IgrIcon >
<span key ="message" > You have lost connection to the internet. This app is offline.</span >
</IgrBanner >
tsx
バナー メッセージで IgrIcon
を使用したい場合は、バナーのコンテンツに挿入するだけです。
<IgrBanner ref ={bannerRef} >
<span key ="message" > You have lost connection to the internet. This app is offline.</span >
<IgrIcon key ="icon" name ="signal_wifi_off" > </IgrIcon >
</IgrBanner >
tsx
バナー ボタンの変更
IgrBanner
は、バナー ボタンをテンプレート化するための actions
スロットを公開します。これにより、デフォルトのバナー ボタン (OK
) をオーバーライドし、ユーザー定義のカスタム操作を追加します。
<IgrBanner ref ={bannerRef} >
<IgrIcon key ="icon" slot ="prefix" name ="signal_wifi_off" > </IgrIcon >
<span key ="message" > You have lost connection to the internet. This app is offline.</span >
<div key ="actions" slot ="actions" >
<IgrButton key ="button" variant ="flat" clicked ={() => bannerRef.current.toggle()}>
<IgrRipple key ="ripple" />
<span key ="action-text" > Toggle Banner</span >
</IgrButton >
</div >
</IgrBanner >
tsx
EXAMPLE
TSX
BannerSample2.css
index.css
import React , { useEffect, useRef } from 'react' ;
import ReactDOM from 'react-dom/client' ;
import {
IgrBanner,
IgrBannerModule,
IgrButton,
IgrButtonModule,
IgrCard,
IgrCardModule,
IgrIcon,
IgrIconModule,
IgrNavbar,
IgrNavbarModule,
IgrRipple,
IgrRippleModule,
} from "@infragistics/igniteui-react" ;
import 'igniteui-webcomponents/themes/light/bootstrap.css' ;
import './BannerSample2.css' ;
import './index.css' ;
import { registerIconFromText } from 'igniteui-webcomponents' ;
IgrBannerModule.register();
IgrNavbarModule.register();
IgrIconModule.register();
IgrCardModule.register();
IgrButtonModule.register();
IgrRippleModule.register();
const refreshIcon =
'<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"/></svg>' ;
const wifiOffIcon =
'<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M23.64 7c-.45-.34-4.93-4-11.64-4-1.5 0-2.89.19-4.15.48L18.18 13.8 23.64 7zm-6.6 8.22L3.27 1.44 2 2.72l2.05 2.06C1.91 5.76.59 6.82.36 7l11.63 14.49.01.01.01-.01 3.9-4.86 3.32 3.32 1.27-1.27-3.46-3.46z"/></svg>' ;
export default function BannerSample2() {
const bannerRef = useRef<IgrBanner > (null );
useEffect(() => {
registerIconFromText('refresh' , refreshIcon);
registerIconFromText('signal_wifi_off' , wifiOffIcon);
bannerRef.current.open = true ;
}, [])
return (
<div className ="gallery__wrapper" >
<div className ="gallery__content" >
<IgrNavbar >
<h1 key ="header" > Gallery</h1 >
<IgrIcon key ="icon-refresh" name ="refresh" slot ="end" onClick ={() => bannerRef.current.show()}></IgrIcon >
</IgrNavbar >
<IgrBanner ref ={bannerRef} className ="offline-banner" >
<IgrIcon key ="icon-wifi-off" name ="signal_wifi_off" slot ="prefix" > </IgrIcon >
<span key ="message" > You have lost connection to the internet. This app is offline.</span >
<div key ="actions" slot ="actions" >
<IgrButton key ="button" variant ="flat" clicked ={() => bannerRef.current.toggle()}>
<IgrRipple key ="ripple" />
<span key ="action-text" > Toggle Banner</span >
</IgrButton >
</div >
</IgrBanner >
<IgrCard className ="gallery__item" elevated >
<div key ="img-forest" >
<img src ="https://www.infragistics.com/angular-demos-lob/assets/images/card/media/the_red_ice_forest.jpg" />
</div >
</IgrCard >
<IgrCard className ="gallery__item" elevated >
<div key ="img-yosemite" >
<img src ="https://www.infragistics.com/angular-demos-lob/assets/images/card/media/yosemite.jpg" />
</div >
</IgrCard >
</div >
</div >
);
}
const root = ReactDOM.createRoot (document.getElementById('root' ));
root.render (<BannerSample2 /> );
tsx コピー .offline-banner {
border-bottom : 1px solid rgba (0 , 0 , 0 , .12 );
}
.gallery__wrapper {
max-width : 400px ;
padding-top : 24px ;
margin : 0 auto;
}
.gallery__content {
display : flex;
flex-flow : column;
max-height : 430px ;
overflow : hidden;
box-shadow : 0 1px 3px 0 rgba (0 ,0 ,0 ,.2 ), 0 1px 1px 0 rgba (0 ,0 ,0 ,.14 ), 0 2px 1px -1px rgba (0 ,0 ,0 ,.12 );
}
.gallery__item {
margin : 8px 16px ;
overflow : visible;
border-radius : 0 ;
& div {
display : flex;
justify-content : center;
}
}
img {
max-width : 100% ;
}
css コピー
イベントにバインド
バナー コンポーネントは、閉じられるときに igcClosing
イベントと igcClosed
イベントを発行します。igcClosing
イベントはキャンセル可能です。CustomEvent
インターフェイスを使用し、発行されたオブジェクトの cancelable
プロパティは true に設定されています。igcClosing
イベントをキャンセルすると、対応する終了アクションとイベントはトリガーされません。バナーは閉じられず、igcClosed
イベントも発行されません。
終了イベントをキャンセルするには、preventDefault
メソッドを呼び出します。
<IgrBanner ref ={bannerRef} >
...
</IgrBanner >
const bannerRef = useRef<IgrBanner > (null );
useEffect(() => {
bannerRef.current.nativeElement.addEventListener('igcClosing' , (event) => {
event.preventDefault();
});
}, [])
tsx
上記が適用されると、終了イベントが常にキャンセルされるため、バナーが閉じることはありません。
高度な例
2 つのカスタムボタンのバナーを作成しましょう。1 つは通知を閉じるためのボタンで、もう 1 つは接続をオンにするためのボタンです。actions
スロットを使用してカスタム アクション ハンドラーを渡すことができます。
<IgrBanner ref ={bannerRef} >
<IgrIcon key ="icon" slot ="prefix" name ="signal_wifi_off" > </IgrIcon >
<span key ="message" > You have lost connection to the internet. This app is offline.</span >
<div key ="actions" slot ="actions" >
<IgrButton key ="button-offline" variant ="flat" clicked ={() => bannerRef.current.hide()}>
<IgrRipple key ="ripple-offline" />
<span key ="action-offline" > Continue Offline</span >
</IgrButton >
<IgrButton key ="button-wifi" variant ="flat" clicked ={() => refreshBanner()}>
<IgrRipple key ="ripple-wifi" />
<span key ="action-wifi" > Turn On Wifi</span >
</IgrButton >
</div >
</IgrBanner >
tsx
Google のマテリアル デザイン ガイドライン では、バナーはに表示するボタンは 2 つまでです。IgrBanner
は、actions
スロットの要素数を明示的に制限しませんが、マテリアル デザイン ガイドに従う場合は、最大 2 つの要素を使用することを強くお勧めします。
閉じるオプション (Continue Offline ) は詳細なロジックを必要としないため、hide
のみの呼び出しが可能です。しかし、確認アクション (Turn On Wifi ) は追加のロジックを必要とするため、コンポーネントで定義する必要があります。次に、click
イベントのイベント リスナーを追加します。最後に、変更するたびに refreshBanner()
メソッドを呼び出します。これにより、wifiState
に基づいてバナーを切り替えます。
ナビゲーション バーには Wi-Fi アイコンが表示され、その click
イベントのイベント リスナーも追加されます。変更ごとに refreshBanner()
メソッドが呼び出されるため、アイコンはバナーを切り替えるだけでなく、接続の状態に応じて変化します。
<IgrNavbar >
<h1 key ="header" > Gallery</h1 >
<IgrIcon ref ={iconRef} key ="icon" name ="signal_wifi_off" slot ="end" onClick ={() => refreshBanner()}></IgrIcon >
</IgrNavbar >
<IgrBanner ref ={bannerRef} >
...
<div key ="actions" slot ="actions" >
...
<IgrButton key ="button-wifi" variant ="flat" clicked ={() => refreshBanner()}>
<IgrRipple key ="ripple-wifi" />
<span key ="action-wifi" > Turn On Wifi</span >
</IgrButton >
</div >
</IgrBanner >
const bannerRef = useRef<IgrBanner > (null );
const iconRef = useRef<IgrIcon > (null );
const [wifiState , setWifiState ] = useState(false );
function refreshBanner() {
if (!wifiState) {
iconRef.current.name = 'signal_wifi_4_bar' ;
bannerRef.current.hide();
} else {
iconRef.current.name = 'signal_wifi_off' ;
bannerRef.current.show();
}
setWifiState(current => !current);
}
tsx
最後に、WiFi の状態に関するメッセージを表示する IgrToast
を追加します。以下はテンプレート化したバナーのデモです。
EXAMPLE
TSX
BannerAdvancedSample.css
index.css
import React , { useEffect, useRef, useState } from 'react' ;
import ReactDOM from 'react-dom/client' ;
import {
IgrBanner,
IgrBannerModule,
IgrButton,
IgrButtonModule,
IgrCard,
IgrCardModule,
IgrIcon,
IgrIconModule,
IgrNavbar,
IgrNavbarModule,
IgrRipple,
IgrRippleModule,
IgrToast,
IgrToastModule,
} from "@infragistics/igniteui-react" ;
import 'igniteui-webcomponents/themes/light/bootstrap.css' ;
import './BannerAdvancedSample.css' ;
import './index.css' ;
import { registerIconFromText } from 'igniteui-webcomponents' ;
IgrBannerModule.register();
IgrNavbarModule.register();
IgrIconModule.register();
IgrCardModule.register();
IgrButtonModule.register();
IgrRippleModule.register();
IgrToastModule.register();
const wifiOnIcon =
'<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M12.01 21.49L23.64 7c-.45-.34-4.93-4-11.64-4C5.28 3 .81 6.66.36 7l11.63 14.49.01.01.01-.01z"/></svg>' ;
const wifiOffIcon =
'<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M23.64 7c-.45-.34-4.93-4-11.64-4-1.5 0-2.89.19-4.15.48L18.18 13.8 23.64 7zm-6.6 8.22L3.27 1.44 2 2.72l2.05 2.06C1.91 5.76.59 6.82.36 7l11.63 14.49.01.01.01-.01 3.9-4.86 3.32 3.32 1.27-1.27-3.46-3.46z"/></svg>' ;
export default function BannerAdvancedSample() {
const bannerRef = useRef<IgrBanner > (null );
const iconRef = useRef<IgrIcon > (null );
const toastRef = useRef<IgrToast > (null );
const [wifiState , setWifiState ] = useState(false );
useEffect(() => {
registerIconFromText('signal_wifi_off' , wifiOffIcon);
registerIconFromText('signal_wifi_4_bar' , wifiOnIcon);
bannerRef.current.open = true ;
}, []);
function refreshBanner() {
if (!wifiState) {
iconRef.current.name = 'signal_wifi_4_bar' ;
bannerRef.current.hide();
} else {
iconRef.current.name = 'signal_wifi_off' ;
bannerRef.current.show();
}
setWifiState(current => !current);
showToast();
}
function showToast() {
toastRef.current.open = false ;
toastRef.current.show();
}
return (
<div className ="gallery__wrapper" >
<div className ="gallery__content" >
<IgrNavbar >
<h1 key ="header" > Gallery</h1 >
<IgrIcon ref ={iconRef} key ="icon-wifi-off" name ="signal_wifi_off" slot ="end" onClick ={() => refreshBanner()}></IgrIcon >
</IgrNavbar >
<IgrBanner ref ={bannerRef} className ="offline-banner" >
<IgrIcon key ="icon-wifi-off" name ="signal_wifi_off" slot ="prefix" > </IgrIcon >
<span key ="message" > You have lost connection to the internet. This app is offline.</span >
<div key ="actions" slot ="actions" >
<IgrButton key ="button-offline" variant ="flat" clicked ={() => bannerRef.current.hide()}>
<IgrRipple key ="ripple-offline" />
<span key ="action-offline" > Continue Offline</span >
</IgrButton >
<IgrButton key ="button-wifi" variant ="flat" clicked ={() => refreshBanner()}>
<IgrRipple key ="ripple-wifi" />
<span key ="action-wifi" > Turn On Wifi</span >
</IgrButton >
</div >
</IgrBanner >
<IgrCard className ="gallery__item" elevated >
<div key ="img-forest" >
<img src ="https://www.infragistics.com/angular-demos-lob/assets/images/card/media/the_red_ice_forest.jpg" />
</div >
</IgrCard >
<IgrCard className ="gallery__item" elevated >
<div key ="img-yosemite" >
<img src ="https://www.infragistics.com/angular-demos-lob/assets/images/card/media/yosemite.jpg" />
</div >
</IgrCard >
<IgrToast ref ={toastRef} position ="middle" >
<span key ="toast-message" > {`Wifi is now ${wifiState ? 'on' : 'off' }`}</span >
</IgrToast >
</div >
</div >
);
}
const root = ReactDOM.createRoot (document.getElementById('root' ));
root.render (<BannerAdvancedSample /> );
tsx コピー .offline-banner {
border-bottom : 1px solid rgba (0 , 0 , 0 , .12 );
}
.gallery__wrapper {
max-width : 400px ;
padding-top : 24px ;
margin : 0 auto;
}
.gallery__content {
display : flex;
flex-flow : column;
max-height : 430px ;
overflow : hidden;
box-shadow : 0 1px 3px 0 rgba (0 ,0 ,0 ,.2 ), 0 1px 1px 0 rgba (0 ,0 ,0 ,.14 ), 0 2px 1px -1px rgba (0 ,0 ,0 ,.12 );
}
.gallery__item {
margin : 8px 16px ;
overflow : visible;
border-radius : 0 ;
& div {
display : flex;
justify-content : center;
}
}
img {
max-width : 100% ;
}
css コピー
スタイル設定
IgrBanner
コンポーネントはいくつかの CSS パーツを公開し、スタイルを完全に制御できるようにします。
名前
説明
base
バナー コンポーネントの基本ラッパー。
spacer
バナーの周囲にスペースを設定する内側のラッパー。
message
テキストとイラストを保持するパーツ。
illustration
バナーのアイコン/イラストを保持するパーツ。
content
バナーのテキスト コンテンツを保持するパーツ。
actions
バナーのアクション ボタンを保持するパーツ。
igc-banner::part (spacer) {
background : var (--ig-surface-600 );
}
igc-banner::part (illustration) {
color : var (--ig-surface-600 -contrast);
}
igc-banner::part (content ) {
color : var (--ig-gray-900 );
}
css
EXAMPLE
TSX
BannerStyling.css
index.css
import React , { useEffect, useRef, useState } from 'react' ;
import ReactDOM from 'react-dom/client' ;
import {
IgrBanner,
IgrBannerModule,
IgrButton,
IgrButtonModule,
IgrCard,
IgrCardModule,
IgrIcon,
IgrIconModule,
IgrNavbar,
IgrNavbarModule,
IgrRipple,
IgrRippleModule,
IgrToast,
IgrToastModule,
} from "@infragistics/igniteui-react" ;
import 'igniteui-webcomponents/themes/light/bootstrap.css' ;
import './BannerStyling.css' ;
import './index.css' ;
import { registerIconFromText } from 'igniteui-webcomponents' ;
IgrBannerModule.register();
IgrNavbarModule.register();
IgrIconModule.register();
IgrCardModule.register();
IgrButtonModule.register();
IgrRippleModule.register();
IgrToastModule.register();
const wifiOnIcon =
'<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M12.01 21.49L23.64 7c-.45-.34-4.93-4-11.64-4C5.28 3 .81 6.66.36 7l11.63 14.49.01.01.01-.01z"/></svg>' ;
const wifiOffIcon =
'<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M23.64 7c-.45-.34-4.93-4-11.64-4-1.5 0-2.89.19-4.15.48L18.18 13.8 23.64 7zm-6.6 8.22L3.27 1.44 2 2.72l2.05 2.06C1.91 5.76.59 6.82.36 7l11.63 14.49.01.01.01-.01 3.9-4.86 3.32 3.32 1.27-1.27-3.46-3.46z"/></svg>' ;
export default function BannerStyling() {
const bannerRef = useRef<IgrBanner > (null );
const iconRef = useRef<IgrIcon > (null );
const toastRef = useRef<IgrToast > (null );
const [wifiState , setWifiState ] = useState(false );
useEffect(() => {
registerIconFromText('signal_wifi_off' , wifiOffIcon);
registerIconFromText('signal_wifi_4_bar' , wifiOnIcon);
bannerRef.current.open = true ;
}, []);
function refreshBanner() {
if (!wifiState) {
iconRef.current.name = 'signal_wifi_4_bar' ;
bannerRef.current.hide();
} else {
iconRef.current.name = 'signal_wifi_off' ;
bannerRef.current.show();
}
setWifiState(current => !current);
showToast();
}
function showToast() {
toastRef.current.open = false ;
toastRef.current.show();
}
return (
<div className ="gallery__wrapper" >
<div className ="gallery__content" >
<IgrNavbar >
<h1 key ="header" > Gallery</h1 >
<IgrIcon ref ={iconRef} key ="icon-wifi-off" name ="signal_wifi_off" slot ="end" onClick ={() => refreshBanner()}></IgrIcon >
</IgrNavbar >
<IgrBanner ref ={bannerRef} className ="offline-banner" >
<IgrIcon key ="icon-wifi-off" name ="signal_wifi_off" slot ="prefix" > </IgrIcon >
<span key ="message" > You have lost connection to the internet. This app is offline.</span >
<div key ="actions" slot ="actions" >
<IgrButton key ="button-offline" variant ="flat" clicked ={() => bannerRef.current.hide()}>
<IgrRipple key ="ripple-offline" />
<span key ="action-offline" > Continue Offline</span >
</IgrButton >
<IgrButton key ="button-wifi" variant ="flat" clicked ={() => refreshBanner()}>
<IgrRipple key ="ripple-wifi" />
<span key ="action-wifi" > Turn On Wifi</span >
</IgrButton >
</div >
</IgrBanner >
<IgrCard className ="gallery__item" elevated >
<div key ="img-forest" >
<img src ="https://www.infragistics.com/angular-demos-lob/assets/images/card/media/the_red_ice_forest.jpg" />
</div >
</IgrCard >
<IgrCard className ="gallery__item" elevated >
<div key ="img-yosemite" >
<img src ="https://www.infragistics.com/angular-demos-lob/assets/images/card/media/yosemite.jpg" />
</div >
</IgrCard >
<IgrToast ref ={toastRef} position ="middle" >
<span key ="toast-message" > {`Wifi is now ${wifiState ? 'on' : 'off' }`}</span >
</IgrToast >
</div >
</div >
);
}
const root = ReactDOM.createRoot (document.getElementById('root' ));
root.render (<BannerStyling /> );
tsx コピー .offline-banner {
border-bottom : 1px solid rgba (0 , 0 , 0 , .12 );
}
.gallery__wrapper {
max-width : 400px ;
padding-top : 24px ;
margin : 0 auto;
}
.gallery__content {
display : flex;
flex-flow : column;
max-height : 430px ;
overflow : hidden;
box-shadow : 0 1px 3px 0 rgba (0 ,0 ,0 ,.2 ), 0 1px 1px 0 rgba (0 ,0 ,0 ,.14 ), 0 2px 1px -1px rgba (0 ,0 ,0 ,.12 );
}
.gallery__item {
margin : 8px 16px ;
overflow : visible;
border-radius : 0 ;
& div {
display : flex;
justify-content : center;
}
}
img {
max-width : 100% ;
}
igc-banner::part (spacer) {
background : #dedede ;
}
igc-banner::part (illustration) {
color : #666666 ;
}
igc-banner::part (content ) {
color : #151515 ;
}
css コピー
API リファレンス
その他のリソース