Web Components 아코디언 개요
Ignite UI for Web Components Accordion은 클릭 가능한 헤더와 관련 콘텐츠 섹션이 있는 수직 확장 가능한 패널을 구축하기 위한 GUI 구성 요소로, 단일 컨테이너에 표시됩니다. 아코디언은 일반적으로 한 페이지에서 콘텐츠의 여러 섹션을 스크롤할 필요성을 줄이는 데 사용됩니다. 기본 패널의 확장 상태를 제어하기 위해 키보드 탐색 및 API를 제공합니다.
사용자는 썸네일이나 라벨과 같은 항목 목록 간에 상호 작용하고 탐색할 수 있습니다. 포함된 정보를 표시하기 위해 각 항목을 전환(확장 또는 축소)할 수 있습니다. 구성에 따라 한 번에 하나 또는 여러 개의 확장된 항목이 있을 수 있습니다.
Web Components 아코디언 예제
다음은 FAQ 섹션의 기본 Ignite UI for Web Components 아코디언 예제입니다. 아코디언으로 작동하며 개별적으로 작업 섹션이 있습니다. 한 번의 클릭으로 각 텍스트 블록을 전환하면서 동시에 여러 패널을 확장할 수 있습니다. 이렇게 하면 자동으로 확장되는 패널과 축소되는 패널 사이를 왔다 갔다 할 필요 없이 정보를 더 쉽게 읽을 수 있으며, 이로 인해 매번 이전에 열었던 섹션이 숨겨집니다.
여기서는 아코디언과 해당 확장 패널을 정의하는 방법을 볼 수 있습니다. 또한 이 샘플은 두 가지 유형의 확장 동작을 보여줍니다. 스위치 버튼은 한 번에 확장할 단일 분기와 다중 분기 사이를 전환하도록 singleExpand
속성을 설정합니다.
import { defineComponents, IgcAccordionComponent, IgcExpansionPanelComponent, IgcSwitchComponent } from "igniteui-webcomponents";
import "igniteui-webcomponents/themes/light/bootstrap.css";
import "./AccordionOverview.css";
defineComponents(IgcAccordionComponent, IgcSwitchComponent);
export class AccordionOverview {
private accordion: IgcAccordionComponent;
private switch: IgcSwitchComponent;
constructor() {
this.accordion = document.getElementById("accordion") as IgcAccordionComponent;
this.switch = document.getElementById("switch") as IgcSwitchComponent;
this.switch.addEventListener("igcChange", (ev: CustomEvent) => {
this.accordion.singleExpand = ev.detail.checked;
});
}
}
new AccordionOverview();
ts<!DOCTYPE html>
<html>
<head>
<title>Accordion Overview</title>
<meta charset="UTF-8" />
<link rel="shortcut icon" href="https://static.infragistics.com/xplatform/images/browsers/wc.png" >
<link rel="stylesheet" href="https://static.infragistics.com/xplatform/css/samples/shared.v6.css" type="text/css" />
</head>
<body>
<div id="root">
<igc-switch id="switch">Single Expand</igc-switch>
<div class="sample-wrapper">
<igc-accordion id="accordion">
<igc-expansion-panel>
<h1 slot="title">What has changed about subscription and pricing model?</h1>
<span>We have moved to a subscription-based pricing model for all our developer tools. This makes it easier
for you to manage your license subscriptions and allows us to provide a better level of service for you. We
updated our pricing and packages to provide you with flexible options and the best value. This includes Ignite UI
(formerly Ignite UI for JavaScript) which includes all of our JavaScript framework components for web development,
including: Angular, ASP.NET (Core and MVC), Blazor, JQuery, React and Web Components), as well as Infragistics Professional,
Infragistics Ultimate, our Ultimate UI products. We also offer multi-year subscriptions options with a built-in discount,
so you can see the value up front. With these updates we are confident that we are providing the best platforms and the best
price.</span>
</igc-expansion-panel>
<igc-expansion-panel>
<h1 slot="title">Who will the updated changes impact?</h1>
<span>The license updates will impact all new and current customers using Ignite UI, Infragistics Professional and
Infragistics Ultimate. Specifically, we have also made updates to our product and packaging for Ignite UI for JavaScript,
Ignite UI for Angular, Ignite UI for React and Ignite UI for Web components. For more information, please refer to this
blog: Announcement: Changes to Ignite UI Product & Packaging The pricing has been updated for all products and packages.
So, all new or additional licenses will be sold based on our new pricing and packages. All existing license agreements will
be honored and renewed based upon the current agreement.</span>
</igc-expansion-panel>
<igc-expansion-panel>
<h1 slot="title">What is the difference between your old model and your current subscription model for Ignite UI?</h1>
<span>For Ignite UI customers, we are moving away from NPM for licensed packages. The current NPM packages will be replaced with
packages that include a “Trial Version” watermark. Licensed packages for Ignite UI will be available from our cloud hosted ProGet
server. For more information, please refer to this article: Moving from Trial to Licensed Ignite UI NPM Packages</span>
</igc-expansion-panel>
<igc-expansion-panel>
<h1 slot="title">What happens if I don't renew my subscription?</h1>
<span>Any unlicensed or trial versions of Ignite UI for Angular, React and Web Components will now include this watermark.</span>
</igc-expansion-panel>
<igc-expansion-panel>
<h1 slot="title">If I don't renew my subscription will I still have access to previous versions of Infragistics products?</h1>
<span>Any version of Infragistics software which you have downloaded can continue to be used perpetually. Access to download any new or
previous versions through our customer portal and package feeds will require maintaining an active subscription by continuing
to renew it.</span>
</igc-expansion-panel>
</igc-accordion>
</div>
</div>
<!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><script src="src/index.ts"></script><% } %>
</body>
</html>
htmligc-accordion {
width: 100%;
}
.sample-wrapper {
overflow-y: auto;
max-height: 380px;
margin: 8px;
}
igc-switch {
padding: 16px;
}
igc-expansion-panel {
border: 1px solid rgba(174, 174, 174, 0.25);
}
css/* shared styles are loaded from: */
/* https://static.infragistics.com/xplatform/css/samples */
css
이 샘플이 마음에 드시나요? 당사의 완전한 Ignite UI for Web Components 툴킷에 액세스하여 몇 분 만에 나만의 앱을 빌드하기 시작하세요. 무료로 다운로드하세요.
Web Components 아코디언 시작하기
먼저 다음 명령을 실행하여 Ignite UI for Web Components 설치해야 합니다.
npm install igniteui-webcomponents
cmd
IgcAccordionComponent
사용하기 전에 다음과 같이 등록해야 합니다.
import { defineComponents, IgcAccordionComponent } from 'igniteui-webcomponents';
defineComponents(IgcAccordionComponent);
ts
Ignite UI for Web Components에 대한 전체 소개를 보려면 시작하기 항목을 읽어보세요.
이제 IgcAccordionComponent
및 해당 패널의 기본 구성으로 시작할 수 있습니다.
용법
Web Components 아코디언 구성 요소의 각 섹션은 Web Components 확장 패널을 사용하여 정의됩니다. 패널은 요구 Open
사항에 따라 패널의 상태를 구성할 수 있는 기능을 제공하는 속성을 제공합니다 Disabled
.
아코디언 선언
아코디언은 그 안에 선언 된 모든 확장 패널을 감쌉니다.
<igc-accordion id="accordion" single-expand="true">
<igc-expansion-panel>
<div slot="title">Title Panel 1</div>
<div>
Content Panel 1
</div>
</igc-expansion-panel>
<igc-expansion-panel>
<div slot="title">Title Panel 2</div>
<div>
Content Panel 2
</div>
</igc-expansion-panel>
</igc-accordion>
html
Panels
접근자를 사용하면 IgcAccordionComponent
의 모든 확장 패널 하위 항목을 포함하는 컬렉션에 대한 참조를 얻을 수 있습니다.
private accordion: IgcAccordionComponent;
private panels: IgcExpansionPanelComponent[];
constructor() {
this.accordion = document.getElementById("accordion") as IgcAccordionComponent;
this.panels = this.accordion.panels;
}
typescript
위에서 설명한 것처럼, singleExpand
속성을 사용하면 한 번에 단일 패널 또는 여러 패널을 확장할 수 있는지 여부를 설정할 수 있습니다.
hideAll
및 showAll
메소드를 사용하면 IgcAccordionComponent
의 모든 IgcExpansionPanelComponent
를 프로그래밍 방식으로 각각 축소 및 확장할 수 있습니다.
SingleExpand 속성이 true로 설정된 경우 showAll 메서드를 호출하면 포커스가 있는 패널만 확장됩니다.
Web Components 아코디언 사용자 정의 예제
Web Components Accordion을 사용하면 헤더와 콘텐츠 패널의 모양을 사용자 지정할 수 있습니다.
아래 샘플은 IgcExpansionPanelComponent
의 내장 슬롯을 사용하여 정교한 필터링 옵션을 구현하는 방법을 보여줍니다.
import {
defineComponents,
IgcAccordionComponent,
IgcCheckboxComponent,
IgcDateTimeInputComponent,
IgcRadioComponent,
IgcRadioGroupComponent,
IgcRangeSliderComponent,
IgcRatingComponent,
registerIconFromText
} from "igniteui-webcomponents";
import "igniteui-webcomponents/themes/light/bootstrap.css";
import "./AccordionCustomization.css";
defineComponents(IgcAccordionComponent, IgcCheckboxComponent, IgcRangeSliderComponent, IgcRadioGroupComponent, IgcRadioComponent, IgcRatingComponent, IgcDateTimeInputComponent);
export class AccordionOverview {
private categories = [
{ checked: false, type: "Bike" },
{ checked: false, type: "Motorcycle" },
{ checked: false, type: "Car" },
{ checked: false, type: "Taxi" },
{ checked: false, type: "Public Transport" }
];
constructor() {
this.registerIcons();
document.querySelectorAll("igc-checkbox").forEach((cb: IgcCheckboxComponent) => cb.addEventListener("igcChange", this.checkCategory));
document.querySelector("igc-range-slider")!.addEventListener("igcChange", this.changeSliderRange);
document.querySelectorAll("igc-radio").forEach((r: IgcRadioComponent) => r.addEventListener("igcChange", this.checkRating));
document.querySelector("igc-date-time-input")!.addEventListener("igcChange", this.hanldeTimeInput);
document.querySelector("igc-icon[name='clear']")!.addEventListener("click", this.clearTime);
}
private checkCategory = (ev: CustomEvent) => {
const type = (ev.target as IgcCheckboxComponent).textContent;
const item = this.categories.find((c) => c.type === type);
if (item) {
item.checked = ev.detail.checked;
}
this.updateCheckedCategories();
};
private updateCheckedCategories() {
let checkedItems = "";
this.categories.forEach((item) => {
if (item.checked) {
checkedItems += checkedItems ? ", " + item.type : "Categories: " + item.type;
}
});
const categoriesTitle = document.querySelector("h1#categories") as HTMLElement;
categoriesTitle.textContent = checkedItems || "Categories";
}
private changeSliderRange = (ev: CustomEvent) => {
const lowerSpan = document.querySelector("span#lowerCost");
const upperSpan = document.querySelector("span#upperCost");
lowerSpan!.textContent = ev.detail.lower;
upperSpan!.textContent = ev.detail.upper;
};
private checkRating = (ev: CustomEvent) => {
const rating = (ev.target as IgcRadioComponent).querySelector("igc-rating")!.label;
const ratingTitle = document.querySelector("h1#rating") as HTMLElement;
ratingTitle.textContent = "Rating: " + rating;
};
private hanldeTimeInput = (ev: CustomEvent) => {
const dateTimeInput = ev.target as IgcDateTimeInputComponent;
if (!dateTimeInput.value) {
return;
}
const timeTitle = document.querySelector("h1#timeTitle") as HTMLElement;
timeTitle.textContent = "Time: " + dateTimeInput.label + " " + dateTimeInput.value.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
};
private clearTime = () => {
document.querySelector("igc-date-time-input")!.clear();
const timeTitle = document.querySelector("h1#timeTitle") as HTMLElement;
timeTitle.textContent = "Time";
};
registerIcons() {
const clearIcon =
"<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' width='24' height='24' viewBox='0 0 24 24'><path d='M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z' /></svg>";
registerIconFromText("clear", clearIcon, "material");
const clockIcon =
"<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' width='24' height='24' viewBox='0 0 24 24'><path d='M12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22C6.47,22 2,17.5 2,12A10,10 0 0,1 12,2M12.5,7V12.25L17,14.92L16.25,16.15L11,13V7H12.5Z' /></svg>";
registerIconFromText("clock", clockIcon, "material");
}
}
new AccordionOverview();
ts<!DOCTYPE html>
<html>
<head>
<title>Accordion Customization</title>
<meta charset="UTF-8" />
<link rel="shortcut icon" href="https://static.infragistics.com/xplatform/images/browsers/wc.png" >
<link rel="stylesheet" href="https://static.infragistics.com/xplatform/css/samples/shared.v6.css" type="text/css" />
</head>
<body>
<div id="root">
<div class="sample-wrapper">
<igc-accordion id="accordion">
<igc-expansion-panel>
<h1 slot="title" id="categories">Categories</h1>
<div class="categories-container">
<igc-checkbox>Bike</igc-checkbox>
<igc-checkbox>Motorcycle</igc-checkbox>
<igc-checkbox>Car</igc-checkbox>
<igc-checkbox>Taxi</igc-checkbox>
<igc-checkbox>Public Transport</igc-checkbox>
</div>
</igc-expansion-panel>
<igc-expansion-panel>
<h1 slot="title">Cost: $<span id="lowerCost">200</span> to $<span id="upperCost">800</span></h1>
<igc-range-slider min="0" max="1000" lower="200" upper="800"></igc-range-slider>
</igc-expansion-panel>
<igc-expansion-panel>
<h1 slot="title" id="rating">Rating</h1>
<igc-radio-group>
<igc-radio name="rating">
<igc-rating class="size-small" label="1 star or more" max="5" value="1.5" readonly></igc-rating>
</igc-radio>
<igc-radio name="rating">
<igc-rating class="size-small" label="2 stars or more" max="5" value="2.5" readonly></igc-rating>
</igc-radio>
<igc-radio name="rating">
<igc-rating class="size-small" label="3 stars or more" max="5" value="3.5" readonly></igc-rating>
</igc-radio>
<igc-radio name="rating">
<igc-rating class="size-small" label="4 stars or more" max="5" value="4.5" readonly></igc-rating>
</igc-radio>
</igc-radio-group>
</igc-expansion-panel>
<igc-expansion-panel>
<h1 slot="title" id="timeTitle">Time</h1>
<igc-date-time-input class="size-small" input-format="hh:mm tt" label="Arrive before">
<igc-icon name="clock" collection="material" slot="prefix"></igc-icon>
<igc-icon name="clear" collection="material" slot="suffix"></igc-icon>
</igc-date-time-input>
</igc-expansion-panel>
</igc-accordion>
</div>
</div>
<!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><script src="src/index.ts"></script><% } %>
</body>
</html>
htmligc-accordion {
width: 100%;
}
.sample-wrapper {
overflow-y: auto;
max-height: 530px;
margin: 8px;
}
igc-range-slider {
margin: 24px;
}
.categories-container {
display: flex;
flex-flow: column nowrap;
}
igc-checkbox,
igc-radio {
margin: 4px 0;
}
igc-expansion-panel {
border: 1px solid rgba(174, 174, 174, 0.25);
}
igc-rating {
flex-direction: row;
}
.size-small {
--ig-size: var(--ig-size-small);
}
css/* shared styles are loaded from: */
/* https://static.infragistics.com/xplatform/css/samples */
css
중첩된 Web Components 아코디언 시나리오
다음 Web Components Accordion 예제에서는 이 일반적인 응용 프로그램 시나리오를 수행하는 방법을 설명하기 위해 복잡한 FAQ 섹션을 만듭니다. 샘플에서 중첩 IgcAccordionComponent
은 확장 패널 내부에 아코디언을 추가하여 수행됩니다.
import { defineComponents, IgcAccordionComponent, IgcExpansionPanelComponent, IgcSwitchComponent } from "igniteui-webcomponents";
import "igniteui-webcomponents/themes/light/bootstrap.css";
import "./AccordionNestedScenario.css";
defineComponents(IgcAccordionComponent, IgcSwitchComponent);
export class AccordionNestedScenario {
private accordion: IgcAccordionComponent;
private switch: IgcSwitchComponent;
constructor() {
this.accordion = document.getElementById("accordion") as IgcAccordionComponent;
this.switch = document.getElementById("switch") as IgcSwitchComponent;
this.switch.addEventListener("igcChange", (ev: CustomEvent) => {
this.accordion.singleExpand = ev.detail.checked;
});
}
}
new AccordionNestedScenario();
ts<!DOCTYPE html>
<html>
<head>
<title>Accordion Nested Scenario</title>
<meta charset="UTF-8" />
<link rel="shortcut icon" href="https://static.infragistics.com/xplatform/images/browsers/wc.png" >
<link rel="stylesheet" href="https://static.infragistics.com/xplatform/css/samples/shared.v6.css" type="text/css" />
</head>
<body>
<div id="root">
<igc-switch id="switch">Single Expand</igc-switch>
<div class="sample-wrapper">
<igc-accordion id="accordion">
<igc-expansion-panel>
<h1 slot="title">What has changed about subscription and pricing model?</h1>
<span>We have moved to a subscription-based pricing model for all our developer tools. This makes it easier
for you to manage your license subscriptions and allows us to provide a better level of service for you. We
updated our pricing and packages to provide you with flexible options and the best value. This includes Ignite UI
(formerly Ignite UI for JavaScript) which includes all of our JavaScript framework components for web development,
including: Angular, ASP.NET (Core and MVC), Blazor, JQuery, React and Web Components), as well as Infragistics Professional,
Infragistics Ultimate, our Ultimate UI products. We also offer multi-year subscriptions options with a built-in discount,
so you can see the value up front. With these updates we are confident that we are providing the best platforms and the best
price.</span>
</igc-expansion-panel>
<igc-expansion-panel>
<h1 slot="title">Who will the updated changes impact?</h1>
<span>The license updates will impact all new and current customers using Ignite UI, Infragistics Professional and
Infragistics Ultimate. Specifically, we have also made updates to our product and packaging for Ignite UI for JavaScript,
Ignite UI for Angular, Ignite UI for React and Ignite UI for Web components. For more information, please refer to this
blog: Announcement: Changes to Ignite UI Product & Packaging The pricing has been updated for all products and packages.
So, all new or additional licenses will be sold based on our new pricing and packages. All existing license agreements will
be honored and renewed based upon the current agreement.</span>
</igc-expansion-panel>
<igc-expansion-panel>
<h1 slot="title">What is the difference between your old model and your current subscription model for Ignite UI?</h1>
<span>For Ignite UI customers, we are moving away from NPM for licensed packages. The current NPM packages will be replaced with
packages that include a “Trial Version” watermark. Licensed packages for Ignite UI will be available from our cloud hosted ProGet
server. For more information, please refer to this article: Moving from Trial to Licensed Ignite UI NPM Packages</span>
</igc-expansion-panel>
<igc-expansion-panel>
<h1 slot="title">Common questions about renewal.</h1>
<igc-accordion>
<igc-expansion-panel>
<h1 slot="title">What happens if I don't renew my subscription?</h1>
<span>Any unlicensed or trial versions of Ignite UI for Angular, React and Web Components will now include this watermark.</span>
</igc-expansion-panel>
<igc-expansion-panel>
<h1 slot="title">If I don't renew my subscription will I still have access to previous versions of Infragistics products?</h1>
<span>Any version of Infragistics software which you have downloaded can continue to be used perpetually. Access to download any new or
previous versions through our customer portal and package feeds will require maintaining an active subscription by continuing
to renew it.</span>
</igc-expansion-panel>
<igc-expansion-panel>
<h1 slot="title">Will I be automatically charged for my renewal/ Can I be automatically charged for renewal?</h1>
<span>Any new subscriptions purchased online, via our eCommerce system, will renew automatically. Subscription renewal can be canceled,
at any time, before the next automatic renewal date. Subscriptions purchased directly from Infragistics or Infragistics' partners are
subject to the renewal terms that were agreed upon as part of that purchase.</span>
</igc-expansion-panel>
</igc-accordion>
</igc-expansion-panel>
<igc-expansion-panel>
<h1 slot="title">I split my work across two computers. Can I install on both using my single-user license?</h1>
<span>The Infragistics Ultimate license is tied to the user, and not the computer. That means you're welcome to install and use Ignite UI,
Infragistics Professional, and Infragistics Ultimate on any computer you use. However, if we notice a large number of activations using the
same license, we may contact you to verify this behavior.</span>
</igc-expansion-panel>
<igc-expansion-panel>
<h1 slot="title">I used up my trial for an earlier version of Infragistics Ultimate. Can I start a new trial when a major version is released?</h1>
<span>Yes! If you have tried a previous version in the past, and used up your 30-day trial, you can try the next major version for another 30 days!
You can do this in the following two ways:
<ul>
<li>If you have days remaining in your 30-day trial period for the current version (e.g., the
Version 15.1 Volume Release), use the Check for Update option inside the Platform Installer or
your account. You will be able to start a fresh trial for the next major version (e.g., 20.1
Volume Release)</li>
<li>If you have used up the 30-day trial for the previous major version (e.g., the 19.2 Volume
Release), simply download and install Infragistics Ultimate from our <a
href="https://www.infragistics.com/products/ultimate">website</a> (This will also allow you
to start a new trial.)</li>
</ul>
</span>
</igc-expansion-panel>
</igc-accordion>
</div>
</div>
<!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><script src="src/index.ts"></script><% } %>
</body>
</html>
htmligc-accordion {
width: 100%;
}
.sample-wrapper {
overflow-y: auto;
max-height: 470px;
margin: 8px;
}
igc-switch {
padding: 16px;
}
igc-expansion-panel {
border: 1px solid rgba(174, 174, 174, 0.25);
}
css/* shared styles are loaded from: */
/* https://static.infragistics.com/xplatform/css/samples */
css
키보드 탐색
Web Components Accordion의 키보드 탐색은 최종 사용자에게 다양한 키보드 상호 작용을 제공합니다. 이 기능은 기본적으로 활성화되어 있으며 최종 사용자가 패널을 쉽게 탐색할 수 있습니다.
Accordion 탐색은 W3C 접근성 표준을 준수하며 사용이 편리합니다.
주요 조합
- ↓- 포커스를 아래 패널로 이동합니다.
- ↑- 포커스를 위 패널로 이동합니다.
- Alt + ↓- 아코디언에서 초점이 맞춰진 패널 열기
- Alt + ↑- 아코디언에서 초점이 맞춰진 패널을 닫습니다.
- Shift + Alt + ↓- 활성화된 모든 패널 열기(singleExpand가 true로 설정된 경우 초점이 맞춰진 패널 열기)
- Shift + Alt + ↑- 활성화된 모든 패널을 닫습니다.
- 홈- 아코디언에서 활성화된 첫 번째 패널로 이동합니다.
- 끝- 아코디언에서 마지막으로 활성화된 패널로 이동합니다.