Skip to content

Commit

Permalink
fix: updated colors and paddins for textarea/textfield
Browse files Browse the repository at this point in the history
  • Loading branch information
vkaltyrin committed Jan 15, 2025
1 parent 8ab0e0d commit 42ac85d
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ struct SDDSTextAreaPreview: PreviewProvider {
counter: "counter",
disabled: false,
readOnly: false,
style: .default,
style: .warning,
labelPlacement: .inner,
required: true,
required: false,
requiredPlacement: .left,
dynamicHeight: true,
appearance: .defaultAppearance,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ extension TextAreaTypography {
public extension ChipAppearance {
static var textArea: ChipAppearance {
ChipAppearance(
titleColor: .surfaceInverseSolidPrimary.withOpacity(0.96),
titleColor: .textDefaultPrimary,
titleTypography: ChipTextFieldTypography.text,
imageTintColor: ColorToken.textDefaultPrimary,
buttonTintColor: ColorToken.textDefaultPrimary,
backgroundColor: .surfaceDefaultSolidPrimary,
imageTintColor: .textDefaultPrimary,
buttonTintColor: .textDefaultPrimary,
backgroundColor: .surfaceDefaultTransparentSecondary,
disabledAlpha: 0.5
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ public enum SDDSTextAreaSize: String, TextAreaSizeConfiguration {
public var captionBottomPadding: CGFloat {
4
}

public var optionalPadding: CGFloat {
4
}

public var textInputPaddings: EdgeInsets {
switch self {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import SDDSComponents
public extension ChipAppearance {
static var textField: ChipAppearance {
ChipAppearance(
titleColor: .surfaceInverseSolidPrimary.withOpacity(0.96),
titleColor: .textDefaultPrimary,
titleTypography: ChipTextFieldTypography.text,
imageTintColor: ColorToken.textDefaultPrimary,
buttonTintColor: ColorToken.textDefaultPrimary,
backgroundColor: .surfaceDefaultSolidPrimary,
imageTintColor: .textDefaultPrimary,
buttonTintColor: .textDefaultPrimary,
backgroundColor: .surfaceDefaultTransparentSecondary,
disabledAlpha: 0.5
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ struct SDDSTextFieldPreview: PreviewProvider {
SDDSTextField(
value: .constant(.single("")),
title: "Title",
optionalTitle: "",
optionalTitle: "optional",
placeholder: "Placeholder",
caption: "caption",
textBefore: "",
textAfter: "",
disabled: false,
readOnly: true,
style: .default,
labelPlacement: .outer,
required: true,
readOnly: false,
style: .warning,
labelPlacement: .inner,
required: false,
requiredPlacement: .right,
appearance: .defaultAppearance,
size: SDDSTextFieldSize.medium,
layout: .default,
layout: .clear,
iconViewProvider: ViewProvider(iconView),
iconActionViewProvider: ViewProvider(iconActionView)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,24 +246,26 @@ public struct SDDSTextArea: View {

@ViewBuilder
private var optionalTitleView: some View {
Text(formattedOptionalTitle)
Text(optionalTitle)
.typography(titleTypography)
.frame(height: titleTypography.lineHeight)
.foregroundColor(appearance.optionalTitleColor.color(for: colorScheme))
.multilineTextAlignment(appearance.titleTextAlignment)
.debug(condition: debugConfiguration.title)
.padding(.leading, size.optionalPadding)
}

@ViewBuilder
private var innerOptionalTitleView: some View {
if required {
EmptyView()
} else {
Text(formattedOptionalTitle)
Text(optionalTitle)
.typography(innerTitleTypography)
.foregroundColor(appearance.optionalTitleColor.color(for: colorScheme))
.multilineTextAlignment(appearance.titleTextAlignment)
.debug(condition: debugConfiguration.title)
.padding(.leading, size.optionalPadding)
}
}

Expand Down Expand Up @@ -315,7 +317,6 @@ public struct SDDSTextArea: View {
.frame(height: calculatedChipGroupHeight)
.padding(.bottom, size.chipGroupVerticalBottomPadding)
.padding(.top, size.chipGroupVerticalTopPadding)
.debug(color: .blue, condition: true)

iconActionView
.padding(.top, size.textInputPaddings.top)
Expand Down Expand Up @@ -413,9 +414,10 @@ public struct SDDSTextArea: View {
if required {
EmptyView()
} else {
Text(" \(optionalTitle)")
Text(optionalTitle)
.typography(textTypography)
.foregroundColor(appearance.optionalTitleColor.color(for: colorScheme))
.padding(.leading, size.optionalPadding)
}
}

Expand Down Expand Up @@ -769,10 +771,6 @@ public struct SDDSTextArea: View {
return min(size.chipGroupHeight, chipGroupContentHeight)
}

private var formattedOptionalTitle: String {
" \(optionalTitle)"
}

private var chipCornerRadius: CGFloat {
switch value {
case .single:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public protocol TextAreaSizeConfiguration: CustomDebugStringConvertible {
var boxTrailingPadding: CGFloat { get }
var captionTopPadding: CGFloat { get }
var captionBottomPadding: CGFloat { get }
var optionalPadding: CGFloat { get }
var textInputPaddings: EdgeInsets { get }
var cornerRadius: CGFloat { get }
var borderWidth: CGFloat { get }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ public struct SDDSTextField: View {
.foregroundColor(appearance.optionalTitleColor.color(for: colorScheme))
.multilineTextAlignment(appearance.titleTextAlignment)
.debug(condition: debugConfiguration.title)
.padding(.leading, size.optionalPadding)
}

@ViewBuilder
Expand Down Expand Up @@ -439,7 +440,7 @@ public struct SDDSTextField: View {

@ViewBuilder
private var innerOrNonePlacementOptionalTitleView: some View {
Text(" \(optionalTitle)")
Text(optionalTitle)
.typography(textTypography)
.foregroundColor(appearance.optionalTitleColor.color(for: colorScheme))
.padding(.leading, size.optionalPadding)
Expand Down Expand Up @@ -582,12 +583,21 @@ public struct SDDSTextField: View {
return appearance.lineColor.color(for: colorScheme)
}
}

private var iconViewColor: Color {
switch style {
case .error, .success, .warning:
return appearance.placeholderColor(for: style, layout: layout).color(for: colorScheme)
case .default:
return appearance.startContentColor.color(for: colorScheme)
}
}

@ViewBuilder
private var iconView: some View {
if let leftView = iconViewProvider?.view {
leftView
.foregroundColor(appearance.startContentColor.color(for: colorScheme))
.foregroundColor(iconViewColor)
.frame(width: iconViewWidth, height: min(size.iconSize.height, size.fieldHeight), debug: debugConfiguration.icon)
.padding(.trailing, size.iconPadding, debug: debugConfiguration.icon)
} else {
Expand Down Expand Up @@ -735,10 +745,6 @@ public struct SDDSTextField: View {
}
}

private var formattedOptionalTitle: String {
" \(optionalTitle)"
}

private var chipCornerRadius: CGFloat {
switch value {
case .single:
Expand Down

0 comments on commit 42ac85d

Please sign in to comment.