Skip to content

Commit

Permalink
feat(Stepper): Add base for example & configurator (#1423)
Browse files Browse the repository at this point in the history
  • Loading branch information
soulcramer authored Jan 13, 2025
1 parent a6a90f4 commit 02aa4c1
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2023 Adevinta
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.adevinta.spark.catalog.configurator.samples.stepper

import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.compose.ui.tooling.preview.Preview
import com.adevinta.spark.catalog.model.Configurator
import com.adevinta.spark.catalog.ui.WipIllustration
import com.adevinta.spark.catalog.util.PreviewTheme
import com.adevinta.spark.catalog.util.SampleSourceUrl

public val StepperConfigurator: Configurator = Configurator(
name = "Stepper",
description = "Stepper configuration",
sourceUrl = "$SampleSourceUrl/StepperSamples.kt",
) {
StepperSample()
}

@Composable
private fun ColumnScope.StepperSample() {
WipIllustration()
}

@Preview
@Composable
private fun PreviewStepperSample() {
PreviewTheme { StepperSample() }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2023 Adevinta
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.adevinta.spark.catalog.examples.samples.stepper

import com.adevinta.spark.catalog.model.Example
import com.adevinta.spark.catalog.ui.WipIllustration
import com.adevinta.spark.catalog.util.SampleSourceUrl

public val StepperExamples: List<Example> = listOf(
Example(
name = "Base Stepper Example",
description = "Base interactions on stepper.",
sourceUrl = "$SampleSourceUrl/RatingDisplaySample.kt",
) {
WipIllustration()
},
Example(
name = "Stepper States",
description = "Disabled, Readonly and all regular states available for the TestField.",
sourceUrl = "$SampleSourceUrl/RatingDisplaySample.kt",
) {
WipIllustration()
},
Example(
name = "Stepper formats",
description = "Stepper can show a suffix like `%`, `€` or `person•s`.",
sourceUrl = "$SampleSourceUrl/RatingInputSample.kt",
) {
WipIllustration()
},
Example(
name = "Stepper Custom Buttons",
description = "Custom implementation allow used defined button for de-increment.",
sourceUrl = "$SampleSourceUrl/RatingFullSample.kt",
) {
WipIllustration()
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import com.adevinta.spark.catalog.configurator.samples.progresstracker.ProgressT
import com.adevinta.spark.catalog.configurator.samples.rating.RatingsConfigurator
import com.adevinta.spark.catalog.configurator.samples.slider.SlidersConfigurator
import com.adevinta.spark.catalog.configurator.samples.snackbar.SnackbarConfigurator
import com.adevinta.spark.catalog.configurator.samples.stepper.StepperConfigurator
import com.adevinta.spark.catalog.configurator.samples.tabs.TabsConfigurator
import com.adevinta.spark.catalog.configurator.samples.tags.TagsConfigurator
import com.adevinta.spark.catalog.configurator.samples.text.TextLinksConfigurator
Expand All @@ -59,6 +60,7 @@ import com.adevinta.spark.catalog.examples.samples.progresstracker.ProgressTrack
import com.adevinta.spark.catalog.examples.samples.rating.RatingExamples
import com.adevinta.spark.catalog.examples.samples.slider.SlidersExamples
import com.adevinta.spark.catalog.examples.samples.snackbar.SnackbarExamples
import com.adevinta.spark.catalog.examples.samples.stepper.StepperExamples
import com.adevinta.spark.catalog.examples.samples.tabs.TabsExamples
import com.adevinta.spark.catalog.examples.samples.tags.TagsExamples
import com.adevinta.spark.catalog.examples.samples.text.DropdownsExamples
Expand Down Expand Up @@ -118,7 +120,6 @@ private val Checkboxes = Component(
private val Chips = Component(
id = nextId(),
name = "Chips",
tintIcon = true,
description = R.string.component_chips_description,
guidelinesUrl = "$ComponentGuidelinesUrl/p/17568d-chip",
docsUrl = "$PackageSummaryUrl/com.adevinta.spark.components.chips/index.html",
Expand Down Expand Up @@ -192,7 +193,6 @@ private val Image = Component(
id = nextId(),
name = "Image",
description = R.string.component_image_description,
tintIcon = true,
guidelinesUrl = "$ComponentGuidelinesUrl/p/096e9f-image",
docsUrl = "$PackageSummaryUrl/com.adevinta.spark.components.image/index.html",
sourceUrl = "$SparkSourceUrl/kotlin/com/adevinta/components/image/Image.kt",
Expand Down Expand Up @@ -252,6 +252,28 @@ private val Rating = Component(
configurator = RatingsConfigurator,
)

private val Snackbars = Component(
id = nextId(),
name = "Snackbars",
description = R.string.component_snackbar_description,
guidelinesUrl = "$ComponentGuidelinesUrl/p/36d4af-snackbar",
docsUrl = "$PackageSummaryUrl/com.adevinta.spark.components.snackbars/index.html",
sourceUrl = "$SparkSourceUrl/kotlin/com/adevinta/spark/components/snackbars/Snackbar.kt",
examples = SnackbarExamples,
configurator = SnackbarConfigurator,
)

private val Stepper = Component(
id = nextId(),
name = "Steppers",
description = R.string.component_stepper_description,
guidelinesUrl = "$ComponentGuidelinesUrl/p/82fbf6-stepper",
docsUrl = "$PackageSummaryUrl/com.adevinta.spark.components.stepper/index.html",
sourceUrl = "$SparkSourceUrl/kotlin/com/adevinta/spark/components/stepper/Stepper.kt",
examples = StepperExamples,
configurator = StepperConfigurator,
)

private val Switches = Component(
id = nextId(),
name = "Switches",
Expand All @@ -265,19 +287,6 @@ private val Switches = Component(
configurator = SwitchConfigurator,
)

private val Snackbars = Component(
id = nextId(),
name = "Snackbars",
illustration = R.drawable.illu_component_placeholder,
tintIcon = false,
description = R.string.component_snackbar_description,
guidelinesUrl = "$ComponentGuidelinesUrl/p/36d4af-snackbar",
docsUrl = "$PackageSummaryUrl/com.adevinta.spark.components.snackbars/index.html",
sourceUrl = "$SparkSourceUrl/kotlin/com/adevinta/spark/components/snackbars/Snackbar.kt",
examples = SnackbarExamples,
configurator = SnackbarConfigurator,
)

private val Tabs = Component(
id = nextId(),
name = "Tabs",
Expand Down Expand Up @@ -319,8 +328,6 @@ private val Dividers = Component(
id = nextId(),
name = "Dividers",
description = R.string.component_divider_description,
illustration = R.drawable.illu_component_placeholder,
tintIcon = false,
guidelinesUrl = "$ComponentGuidelinesUrl/p/867b47-divider",
docsUrl = "$PackageSummaryUrl/com.adevinta.spark.components.divider/index.html",
sourceUrl = "$SparkSourceUrl/kotlin/com/adevinta/components/divider/Divider.kt",
Expand Down Expand Up @@ -358,8 +365,6 @@ private val Sliders = Component(
id = nextId(),
name = "Slider",
description = R.string.component_slider_description,
illustration = R.drawable.illu_component_placeholder,
tintIcon = false,
guidelinesUrl = "$ComponentGuidelinesUrl/p/25cceb-slider/b/",
docsUrl = "$PackageSummaryUrl/com.adevinta.spark.components.slider/index.html",
sourceUrl = "$SparkSourceUrl/kotlin/com/adevinta/components/slider/Slider.kt",
Expand Down Expand Up @@ -410,11 +415,12 @@ public val Components: List<Component> = listOf(
ProgressTracker,
RadioButtons,
Rating,
Sliders,
Snackbars,
Stepper,
Switches,
Tabs,
Tags,
TextFields,
TextLinks,
Sliders,
Snackbars,
)
4 changes: 4 additions & 0 deletions catalog/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@
<!--region Switch-->
<string name="component_switch_description">Switch component allows the user to activate or deactivate the state of an element or concept. It is also used to control binary options (On/Off or True/False).</string>

<!--endregion-->
<!--region Stepper-->
<string name="component_stepper_description">The Stepper allow users to quickly specify a value within a given range.</string>

<!--endregion-->
<string name="component_progressbar_description">The progress bar component is used to display the length and your progression inside the process or to express a waiting time. This waiting time can be either determinate or indeterminate..</string>
<string name="component_tag_description">Tags are used to label content and help users quickly recognize info about them: Categories, Status… Can be applied with different colors and designs that are associated with a content due to its characteristics: new content, unvisited content, featured content… Users can’t interact with Tags.</string>
Expand Down

0 comments on commit 02aa4c1

Please sign in to comment.