Skip to content

Commit 42ac85d

Browse files
committed
fix: updated colors and paddins for textarea/textfield
1 parent 8ab0e0d commit 42ac85d

File tree

8 files changed

+39
-30
lines changed

8 files changed

+39
-30
lines changed

Diff for: SDDSComponents/SDDSComponentsPreview/Components/SDDSTextArea/SDDSTextArea+Preview.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ struct SDDSTextAreaPreview: PreviewProvider {
2929
counter: "counter",
3030
disabled: false,
3131
readOnly: false,
32-
style: .default,
32+
style: .warning,
3333
labelPlacement: .inner,
34-
required: true,
34+
required: false,
3535
requiredPlacement: .left,
3636
dynamicHeight: true,
3737
appearance: .defaultAppearance,

Diff for: SDDSComponents/SDDSComponentsPreview/Components/SDDSTextArea/SDDSTextAreaAppearance+Extensions.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ extension TextAreaTypography {
124124
public extension ChipAppearance {
125125
static var textArea: ChipAppearance {
126126
ChipAppearance(
127-
titleColor: .surfaceInverseSolidPrimary.withOpacity(0.96),
127+
titleColor: .textDefaultPrimary,
128128
titleTypography: ChipTextFieldTypography.text,
129-
imageTintColor: ColorToken.textDefaultPrimary,
130-
buttonTintColor: ColorToken.textDefaultPrimary,
131-
backgroundColor: .surfaceDefaultSolidPrimary,
129+
imageTintColor: .textDefaultPrimary,
130+
buttonTintColor: .textDefaultPrimary,
131+
backgroundColor: .surfaceDefaultTransparentSecondary,
132132
disabledAlpha: 0.5
133133
)
134134
}

Diff for: SDDSComponents/SDDSComponentsPreview/Components/SDDSTextArea/SDDSTextAreaSize.swift

+4
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ public enum SDDSTextAreaSize: String, TextAreaSizeConfiguration {
101101
public var captionBottomPadding: CGFloat {
102102
4
103103
}
104+
105+
public var optionalPadding: CGFloat {
106+
4
107+
}
104108

105109
public var textInputPaddings: EdgeInsets {
106110
switch self {

Diff for: SDDSComponents/SDDSComponentsPreview/Components/SDDSTextField/ChipAppearance+SDDSTextField.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import SDDSComponents
66
public extension ChipAppearance {
77
static var textField: ChipAppearance {
88
ChipAppearance(
9-
titleColor: .surfaceInverseSolidPrimary.withOpacity(0.96),
9+
titleColor: .textDefaultPrimary,
1010
titleTypography: ChipTextFieldTypography.text,
11-
imageTintColor: ColorToken.textDefaultPrimary,
12-
buttonTintColor: ColorToken.textDefaultPrimary,
13-
backgroundColor: .surfaceDefaultSolidPrimary,
11+
imageTintColor: .textDefaultPrimary,
12+
buttonTintColor: .textDefaultPrimary,
13+
backgroundColor: .surfaceDefaultTransparentSecondary,
1414
disabledAlpha: 0.5
1515
)
1616
}

Diff for: SDDSComponents/SDDSComponentsPreview/Components/SDDSTextField/SDDSTextField+Preview.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@ struct SDDSTextFieldPreview: PreviewProvider {
2525
SDDSTextField(
2626
value: .constant(.single("")),
2727
title: "Title",
28-
optionalTitle: "",
28+
optionalTitle: "optional",
2929
placeholder: "Placeholder",
3030
caption: "caption",
3131
textBefore: "",
3232
textAfter: "",
3333
disabled: false,
34-
readOnly: true,
35-
style: .default,
36-
labelPlacement: .outer,
37-
required: true,
34+
readOnly: false,
35+
style: .warning,
36+
labelPlacement: .inner,
37+
required: false,
3838
requiredPlacement: .right,
3939
appearance: .defaultAppearance,
4040
size: SDDSTextFieldSize.medium,
41-
layout: .default,
41+
layout: .clear,
4242
iconViewProvider: ViewProvider(iconView),
4343
iconActionViewProvider: ViewProvider(iconActionView)
4444
)

Diff for: SDDSComponents/Sources/SDDSComponents/Components/SDDSTextArea/SDDSTextArea.swift

+6-8
Original file line numberDiff line numberDiff line change
@@ -246,24 +246,26 @@ public struct SDDSTextArea: View {
246246

247247
@ViewBuilder
248248
private var optionalTitleView: some View {
249-
Text(formattedOptionalTitle)
249+
Text(optionalTitle)
250250
.typography(titleTypography)
251251
.frame(height: titleTypography.lineHeight)
252252
.foregroundColor(appearance.optionalTitleColor.color(for: colorScheme))
253253
.multilineTextAlignment(appearance.titleTextAlignment)
254254
.debug(condition: debugConfiguration.title)
255+
.padding(.leading, size.optionalPadding)
255256
}
256257

257258
@ViewBuilder
258259
private var innerOptionalTitleView: some View {
259260
if required {
260261
EmptyView()
261262
} else {
262-
Text(formattedOptionalTitle)
263+
Text(optionalTitle)
263264
.typography(innerTitleTypography)
264265
.foregroundColor(appearance.optionalTitleColor.color(for: colorScheme))
265266
.multilineTextAlignment(appearance.titleTextAlignment)
266267
.debug(condition: debugConfiguration.title)
268+
.padding(.leading, size.optionalPadding)
267269
}
268270
}
269271

@@ -315,7 +317,6 @@ public struct SDDSTextArea: View {
315317
.frame(height: calculatedChipGroupHeight)
316318
.padding(.bottom, size.chipGroupVerticalBottomPadding)
317319
.padding(.top, size.chipGroupVerticalTopPadding)
318-
.debug(color: .blue, condition: true)
319320

320321
iconActionView
321322
.padding(.top, size.textInputPaddings.top)
@@ -413,9 +414,10 @@ public struct SDDSTextArea: View {
413414
if required {
414415
EmptyView()
415416
} else {
416-
Text(" \(optionalTitle)")
417+
Text(optionalTitle)
417418
.typography(textTypography)
418419
.foregroundColor(appearance.optionalTitleColor.color(for: colorScheme))
420+
.padding(.leading, size.optionalPadding)
419421
}
420422
}
421423

@@ -769,10 +771,6 @@ public struct SDDSTextArea: View {
769771
return min(size.chipGroupHeight, chipGroupContentHeight)
770772
}
771773

772-
private var formattedOptionalTitle: String {
773-
" \(optionalTitle)"
774-
}
775-
776774
private var chipCornerRadius: CGFloat {
777775
switch value {
778776
case .single:

Diff for: SDDSComponents/Sources/SDDSComponents/Components/SDDSTextArea/TextAreaSizeConfiguration.swift

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public protocol TextAreaSizeConfiguration: CustomDebugStringConvertible {
99
var boxTrailingPadding: CGFloat { get }
1010
var captionTopPadding: CGFloat { get }
1111
var captionBottomPadding: CGFloat { get }
12+
var optionalPadding: CGFloat { get }
1213
var textInputPaddings: EdgeInsets { get }
1314
var cornerRadius: CGFloat { get }
1415
var borderWidth: CGFloat { get }

Diff for: SDDSComponents/Sources/SDDSComponents/Components/SDDSTextField/SDDSTextField.swift

+12-6
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ public struct SDDSTextField: View {
247247
.foregroundColor(appearance.optionalTitleColor.color(for: colorScheme))
248248
.multilineTextAlignment(appearance.titleTextAlignment)
249249
.debug(condition: debugConfiguration.title)
250+
.padding(.leading, size.optionalPadding)
250251
}
251252

252253
@ViewBuilder
@@ -439,7 +440,7 @@ public struct SDDSTextField: View {
439440

440441
@ViewBuilder
441442
private var innerOrNonePlacementOptionalTitleView: some View {
442-
Text(" \(optionalTitle)")
443+
Text(optionalTitle)
443444
.typography(textTypography)
444445
.foregroundColor(appearance.optionalTitleColor.color(for: colorScheme))
445446
.padding(.leading, size.optionalPadding)
@@ -582,12 +583,21 @@ public struct SDDSTextField: View {
582583
return appearance.lineColor.color(for: colorScheme)
583584
}
584585
}
586+
587+
private var iconViewColor: Color {
588+
switch style {
589+
case .error, .success, .warning:
590+
return appearance.placeholderColor(for: style, layout: layout).color(for: colorScheme)
591+
case .default:
592+
return appearance.startContentColor.color(for: colorScheme)
593+
}
594+
}
585595

586596
@ViewBuilder
587597
private var iconView: some View {
588598
if let leftView = iconViewProvider?.view {
589599
leftView
590-
.foregroundColor(appearance.startContentColor.color(for: colorScheme))
600+
.foregroundColor(iconViewColor)
591601
.frame(width: iconViewWidth, height: min(size.iconSize.height, size.fieldHeight), debug: debugConfiguration.icon)
592602
.padding(.trailing, size.iconPadding, debug: debugConfiguration.icon)
593603
} else {
@@ -735,10 +745,6 @@ public struct SDDSTextField: View {
735745
}
736746
}
737747

738-
private var formattedOptionalTitle: String {
739-
" \(optionalTitle)"
740-
}
741-
742748
private var chipCornerRadius: CGFloat {
743749
switch value {
744750
case .single:

0 commit comments

Comments
 (0)