From 72093774ae6ba20409116bf9bbf0d580c375c156 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Lapersonne Date: Wed, 29 Jan 2025 09:45:20 +0100 Subject: [PATCH] chore: define option, state, hierharchy and style (#264) Signed-off-by: Pierre-Yves Lapersonne --- .../Sources/Checkbox/OUDSCheckbox.swift | 101 ++++++++++++++++++ .../_OUDSComponents.docc/OUDSComponents.md | 1 + 2 files changed, 102 insertions(+) create mode 100644 OUDS/Core/Components/Sources/Checkbox/OUDSCheckbox.swift diff --git a/OUDS/Core/Components/Sources/Checkbox/OUDSCheckbox.swift b/OUDS/Core/Components/Sources/Checkbox/OUDSCheckbox.swift new file mode 100644 index 0000000000..27a23ddcd0 --- /dev/null +++ b/OUDS/Core/Components/Sources/Checkbox/OUDSCheckbox.swift @@ -0,0 +1,101 @@ +// +// Software Name: OUDS iOS +// SPDX-FileCopyrightText: Copyright (c) Orange SA +// SPDX-License-Identifier: MIT +// +// This software is distributed under the MIT license, +// the text of which is available at https://opensource.org/license/MIT/ +// or see the "LICENSE" file for more details. +// +// Authors: See CONTRIBUTORS.txt +// Software description: A SwiftUI components library with code examples for Orange Unified Design System +// + +import OUDSFoundations +import SwiftUI + +// MARK: - OUDS Checbkox + +/// The ``OUDSChebckbox`` proposes... +/// +/// ## Hierarchies +/// +/// ## Code samples +/// +/// ## Styles +/// +/// ## Colored Surface +/// +/// ## Design documentation +/// +/// - Since: 0.11.0 +public struct OUDSCheckbox: View { + + // MARK: - Layout + + /// The type of layouts or, in the end, checkbox component to use + public enum Layout { + + /// A checkbox with a box to fill and a label + case `default` + + /// Only a checkbox, without text + case selectorOnly + + /// A checkbox with a box to fill and a label, but inverse, i.e. with a trailing checkbox + case inverseDefault + + /// Only a checkbox, without text, but inverse, i.e. with a trailing checkbox + case inverseSelectorOnly + } + + // MARK: - Status + + /// Represents the status of a checkbox i.e. a kind of type or status + public enum Status { + /// The checkbox is selected + case selected + + /// The checkbox is not selected + case unselected + + /// The checkbox is in an undeterminate state, i.e. preselected for example + case undeterminate + + /// The checkbox is selected but is related to an error situation + case errorSelected + + /// The checkbox is not selectedbut is related to an error situation + case errorUnselected + + /// The checbkox is in an undeterminate state, i.e. preselected for example, but is related to an error situation + case errorUndeterminate + } + + // MARK: - Options + + public enum Option { + + /// Add an icon in the opposite of the checkbox. + /// If checkbox is in leading position, icon is in trailing position. + /// If checkbox is in trailng position, icon is in leading position. + case withIcon + + /// Add an helper text below the label + case withHelperText + + /// Add a diviser bellow the layout of the component + case withDivider + } + + // MARK: - State + + /// Defines the state of the checkbox, e.g. loading or not, for the style + public enum State { + /// The default style, the checkbox could be in states: enabled, disabled, hover, pressed, focused, read only, skeleton + case `default` + + /// The loading style means a loading action is in progress, sometimes just after user tapped on chekcbix + case loading + } +} diff --git a/OUDS/Core/Components/Sources/_OUDSComponents.docc/OUDSComponents.md b/OUDS/Core/Components/Sources/_OUDSComponents.docc/OUDSComponents.md index e6a3fe6402..fe6f7b9068 100644 --- a/OUDS/Core/Components/Sources/_OUDSComponents.docc/OUDSComponents.md +++ b/OUDS/Core/Components/Sources/_OUDSComponents.docc/OUDSComponents.md @@ -102,3 +102,4 @@ The helper is available through `View`, and tokens through the provider of the t ### Group - ``OUDSButton`` +- ``OUDSCheckbox``