Skip to content

Commit

Permalink
refactor(Phone): remove css import and integrate base styles
Browse files Browse the repository at this point in the history
  • Loading branch information
MicaelRodrigues committed Jan 27, 2023
1 parent 99365e8 commit 31d807d
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 53 deletions.
61 changes: 34 additions & 27 deletions packages/yoga/src/Input/web/Phone.style.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'react-phone-input-2/lib/material.css';
import styled, { css } from 'styled-components';
import { flagsSprite, chevronSvg, checkSvg } from './data-images';

Expand Down Expand Up @@ -48,13 +47,6 @@ const flagsPositioning = css`
}
`;

const flagReset = css`
position: relative;
top: initial;
left: initial;
margin-top: 0;
`;

const hiddenScrollBar = css`
::-webkit-scrollbar {
display: none;
Expand Down Expand Up @@ -93,7 +85,9 @@ export const Container = styled.div`
},
}) => css`
.react-tel-input {
width: inherit;
box-sizing: border-box;
position: relative;
width: 100%;
height: inherit;
font-family: ${baseFont.family}, sans-serif;
font-size: ${input.font.size}px;
Expand All @@ -103,8 +97,12 @@ export const Container = styled.div`
grid-template-columns: min-content 1fr;
.special-label {
z-index: unset;
left: unset;
position: absolute;
top: -${spacing.xxsmall}px;
display: block;
background: white;
padding: 0 ${spacing.xxxsmall}px;
white-space: nowrap;
font-size: ${input.label.font.size.typed}px;
color: ${input.label.color.default};
letter-spacing: normal;
Expand All @@ -119,14 +117,18 @@ export const Container = styled.div`
}
}
input[disabled] + .flag-dropdown:hover {
cursor: not-allowed;
}
.form-control {
background: transparent;
border: unset;
padding: unset;
box-sizing: border-box;
border: none;
width: 100%;
outline: none;
grid-area: input;
color: ${disabled ? colors.text.disabled : input.font.color.focus};
font-family: ${baseFont.family}, sans-serif;
font-size: ${input.font.size}px;
padding-left: ${spacing.xsmall}px;
Expand All @@ -151,10 +153,6 @@ export const Container = styled.div`
.flag-dropdown {
border: none;
width: inherit;
position: unset;
top: unset;
bottom: unset;
padding: unset;
grid-area: dropdown;
&.open {
Expand All @@ -166,15 +164,18 @@ export const Container = styled.div`
&.open .selected-flag,
&:hover,
&:focus {
cursor: pointer;
background: transparent;
}
}
.selected-flag {
border: none;
display: flex;
position: relative;
width: 52px;
height: 100%;
padding: 0;
padding-left: ${spacing.xxxsmall}px;
display: flex;
align-items: center;
opacity: ${disabled ? 0.5 : 1};
Expand All @@ -190,19 +191,17 @@ export const Container = styled.div`
}
.flag {
${flagReset};
display: flex;
align-items: center;
.arrow {
background-color: ${input.label.color.default};
mask-image: url('data:image/svg+xml;utf8,${chevronSvg}');
border: none;
top: unset;
margin-top: unset;
width: 16px;
height: 16px;
transition: 0.6s, color 0.1s;
position: relative;
left: ${spacing.large + spacing.xxxsmall}px;
&.up {
border: none;
Expand All @@ -222,13 +221,18 @@ export const Container = styled.div`
width: 20px;
height: 20px;
background-image: url('data:image/png;base64,${flagsSprite}');
background-repeat: no-repeat;
}
${flagsPositioning};
.country-list {
box-shadow: none;
border-radius: unset;
background-color: white;
position: absolute;
padding: 0;
outline: none;
overflow-y: scroll;
list-style: none;
max-height: 18rem;
margin: -${spacing.xxsmall}px 0 0 calc(-1 * var(--fieldset-left-offset) -
1px);
Expand All @@ -250,10 +254,13 @@ export const Container = styled.div`
color: ${input.font.color.focus};
.flag {
${flagReset};
margin-right: ${spacing.small}px;
}
.country-name {
margin-right: ${spacing.xxxsmall}px;
}
.dial-code {
color: inherit;
display: flex;
Expand Down
61 changes: 35 additions & 26 deletions packages/yoga/src/Input/web/__snapshots__/Phone.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ exports[`<Input.Phone /> Snapshots should match with default input 1`] = `
}
.c2 .react-tel-input {
width: inherit;
box-sizing: border-box;
position: relative;
width: 100%;
height: inherit;
font-family: Rubik,sans-serif;
font-size: 14px;
Expand All @@ -68,8 +70,12 @@ exports[`<Input.Phone /> Snapshots should match with default input 1`] = `
}
.c2 .react-tel-input .special-label {
z-index: unset;
left: unset;
position: absolute;
top: -8px;
display: block;
background: white;
padding: 0 4px;
white-space: nowrap;
font-size: 12px;
color: #6B6B78;
-webkit-letter-spacing: normal;
Expand All @@ -82,14 +88,18 @@ exports[`<Input.Phone /> Snapshots should match with default input 1`] = `
color: #231B22;
}
.c2 .react-tel-input input[disabled] + .flag-dropdown:hover {
cursor: not-allowed;
}
.c2 .react-tel-input .form-control {
background: transparent;
border: unset;
padding: unset;
box-sizing: border-box;
border: none;
width: 100%;
outline: none;
grid-area: input;
color: #231B22;
font-family: Rubik,sans-serif;
font-size: 14px;
padding-left: 12px;
}
Expand Down Expand Up @@ -126,10 +136,6 @@ exports[`<Input.Phone /> Snapshots should match with default input 1`] = `
.c2 .react-tel-input .flag-dropdown {
border: none;
width: inherit;
position: unset;
top: unset;
bottom: unset;
padding: unset;
grid-area: dropdown;
}
Expand All @@ -142,17 +148,20 @@ exports[`<Input.Phone /> Snapshots should match with default input 1`] = `
.c2 .react-tel-input .flag-dropdown.open .selected-flag,
.c2 .react-tel-input .flag-dropdown:hover,
.c2 .react-tel-input .flag-dropdown:focus {
cursor: pointer;
background: transparent;
}
.c2 .react-tel-input .selected-flag {
border: none;
padding: 0;
padding-left: 4px;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
position: relative;
width: 52px;
height: 100%;
padding: 0;
padding-left: 4px;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
Expand All @@ -174,10 +183,6 @@ exports[`<Input.Phone /> Snapshots should match with default input 1`] = `
}
.c2 .react-tel-input .selected-flag .flag {
position: relative;
top: initial;
left: initial;
margin-top: 0;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
Expand All @@ -192,13 +197,12 @@ exports[`<Input.Phone /> Snapshots should match with default input 1`] = `
background-color: #6B6B78;
-webkit-mask-image: url('data:image/svg+xml;utf8,%0A%20%20%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220%200%2012%2012%22%3E%0A%20%20%20%20%3Cpath%20fill-rule=%22evenodd%22%20d=%22M3.146%204.146a.5.5%200%200%201%20.708%200L6%206.293l2.146-2.147a.5.5%200%200%201%20.708.708l-2.5%202.5a.5.5%200%200%201-.708%200l-2.5-2.5a.5.5%200%200%201%200-.708Z%22%20clip-rule=%22evenodd%22/%3E%0A%20%20%3C/svg%3E%0A');
mask-image: url('data:image/svg+xml;utf8,%0A%20%20%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220%200%2012%2012%22%3E%0A%20%20%20%20%3Cpath%20fill-rule=%22evenodd%22%20d=%22M3.146%204.146a.5.5%200%200%201%20.708%200L6%206.293l2.146-2.147a.5.5%200%200%201%20.708.708l-2.5%202.5a.5.5%200%200%201-.708%200l-2.5-2.5a.5.5%200%200%201%200-.708Z%22%20clip-rule=%22evenodd%22/%3E%0A%20%20%3C/svg%3E%0A');
border: none;
top: unset;
margin-top: unset;
width: 16px;
height: 16px;
-webkit-transition: 0.6s,color 0.1s;
transition: 0.6s,color 0.1s;
position: relative;
left: 28px;
}
.c2 .react-tel-input .selected-flag .flag .arrow.up {
Expand All @@ -218,6 +222,7 @@ exports[`<Input.Phone /> Snapshots should match with default input 1`] = `
width: 20px;
height: 20px;
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAAA8CAYAAADxJz2MAAAAAXNSR0IArs4c6QAAEBZJREFUeF7NXHlwXMWZ//XoGB86ZnwIc1hostYBjrM+CCZYWTvYZCvYRIdZAnLIaljA2PEhkQXbRcUa7W7WmCRYSmxnnThItVhaUottTZBIeTEpREQKFz6mloA1EqyeBXb5nifJthgdr7e+N/NGb2bem3lvZli2/8Kj7l9//Xtf99f9/bph0CjLXNw2OHWwmnHLUg4+n4EVBKt5AAgc3H3yuZxmrbZav9U0LbONZ1iqYbEsZWDzOecyHgPzcMYFcMn9yzV/NIX37flPVN/rWLUUwHwAin0CAE96f4c762trDOOh/LANlozqfU8VLy2/1jvf91CtjDf9yH7PIT5LWPvr024c+q4mHosc8KKdg+WwsCZw2GITxAQOqT4ekRtal5czzpqAe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3wPPDMH47Y75X/7v1qDK64jchSOKEJx72xRrbEkZykXNr8/8U6EHuzM+8SPK7snti+5FVORfms6Pn1MffVWt1c5I5OcTeGt2caWFVEpfcUDfX+uQUE/3fuZKEJ+Gez3NkDHA1Hco61hJGr0pvcnWu5cCIy4b+DijhFYV/4N/B3vwP4DC6b9fRZ67zprqIsSeHVPX4YAIirFJPCND5tg7W3CspELcrNjGdMhFj+JB+50fqkEXtqbiZn/3YaLt6/48gnc1Hp/X+Q7DMUDxeFL2PPOP+LzsYDwPCljKn74zZ/BNnmmHoGe4p58m4HLmUY/tmfzcRbSRCpnA0vGxyCUnQdYFsCvw+G+CdeP+XF+61UjmJ4SeBcYqWi0TtwgQiT+ua9dxrvXsUomj8qXEUToYvqWuUD25THcODaCqYszQevPp9+/BAomBkrqg8jGA/fVRL7DSHQbQ1nfvB/PsEnieEo0EWthuvP5aZOiNJGv2YC7z/gx/dAQrpnYxqiz0gbINlSFab3rSJDAL0Rz0Ht3ksBGOuURmBiWI1Kk5pAIgeqvm2qNRUsTMUvgF+F9IQKDJIbedZglUEtzSLXGEvnuxAyBWvYZmp8GKoXtiZR3HSYJ1NUcUq2xqN+dmCBQ1z4D/MStErWppLPxNxyr6h648/GYmshgzQ5xuPlwXE0kWc0hcgTKO5G7Dg4VxMkHGtJE4jIUp4Lurjz4P6OgKxATGsbEM4dOuk0fvI1qyIZENQc98I575lfPec9fZlbDMGSsiUr/C+U5BKMm6UjbAAAAAElFTkSuQmCC');
background-repeat: no-repeat;
}
.c2 .react-tel-input .ar {
Expand Down Expand Up @@ -265,8 +270,12 @@ exports[`<Input.Phone /> Snapshots should match with default input 1`] = `
}
.c2 .react-tel-input .country-list {
box-shadow: none;
border-radius: unset;
background-color: white;
position: absolute;
padding: 0;
outline: none;
overflow-y: scroll;
list-style: none;
max-height: 18rem;
margin: -8px 0 0 calc(-1 * var(--fieldset-left-offset) - 1px);
width: calc(100% + var(--fieldset-left-offset) + 2px);
Expand Down Expand Up @@ -301,13 +310,13 @@ exports[`<Input.Phone /> Snapshots should match with default input 1`] = `
}
.c2 .react-tel-input .country-list .country .flag {
position: relative;
top: initial;
left: initial;
margin-top: 0;
margin-right: 16px;
}
.c2 .react-tel-input .country-list .country .country-name {
margin-right: 4px;
}
.c2 .react-tel-input .country-list .country .dial-code {
color: inherit;
display: -webkit-box;
Expand Down

0 comments on commit 31d807d

Please sign in to comment.