From 9103c403b2c3018468bb1a99e73cfeb82ac61e61 Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Mon, 23 Sep 2024 16:18:37 -0400 Subject: [PATCH] docs(segment-view): document setContent method and add example --- core/src/components.d.ts | 5 +++ .../components/segment-view/segment-view.tsx | 7 ++++ .../segment-view/test/basic/index.html | 33 +++++++++++++++++-- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/core/src/components.d.ts b/core/src/components.d.ts index 9dc45dc769..ccf4016619 100644 --- a/core/src/components.d.ts +++ b/core/src/components.d.ts @@ -2723,6 +2723,11 @@ export namespace Components { * If `true`, the segment view cannot be interacted with. */ "disabled": boolean; + /** + * This method is used to programmatically set the displayed segment content in the segment view. Calling this method will update the `value` of the corresponding segment button. + * @param id : The id of the segment content to display. + * @param smoothScroll : Whether to animate the scroll transition. + */ "setContent": (id: string, smoothScroll?: boolean) => Promise; } interface IonSelect { diff --git a/core/src/components/segment-view/segment-view.tsx b/core/src/components/segment-view/segment-view.tsx index 81678a33ed..f519de30ff 100644 --- a/core/src/components/segment-view/segment-view.tsx +++ b/core/src/components/segment-view/segment-view.tsx @@ -36,6 +36,13 @@ export class SegmentView implements ComponentInterface { } } + /** + * This method is used to programmatically set the displayed segment content + * in the segment view. Calling this method will update the `value` of the + * corresponding segment button. + * @param id: The id of the segment content to display. + * @param smoothScroll: Whether to animate the scroll transition. + */ @Method() async setContent(id: string, smoothScroll = true) { const contents = this.getSegmentContents(); diff --git a/core/src/components/segment-view/test/basic/index.html b/core/src/components/segment-view/test/basic/index.html index 093d1d064b..922e865901 100644 --- a/core/src/components/segment-view/test/basic/index.html +++ b/core/src/components/segment-view/test/basic/index.html @@ -48,7 +48,7 @@ - + No @@ -57,7 +57,7 @@ - + No Value @@ -76,6 +76,7 @@ Favorites + Paid @@ -112,6 +113,14 @@ Reading List Shared Links + + + + @@ -119,6 +128,26 @@ Footer + +