Skip to content

Commit 34fc712

Browse files
authored
style: make the resources form responsive (#276)
1 parent 1d92709 commit 34fc712

File tree

4 files changed

+50
-5
lines changed

4 files changed

+50
-5
lines changed

packages/cms/form/belongs-to-many/belongs-to-many.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,21 @@ const AddButtonsWrapper = styled.div`
6161
display: flex;
6262
align-items: center;
6363
gap: 4px;
64+
65+
@media only screen and (max-width: 767px) {
66+
display: block;
67+
}
6468
`
6569

6670
const CreateActionButtonsWrapper = styled.div`
6771
display: flex;
6872
align-items: center;
6973
justify-content: center;
7074
gap: 8px;
75+
76+
@media only screen and (max-width: 767px) {
77+
display: block;
78+
}
7179
`
7280

7381
const CreateResourceWrapper = styled.div`

packages/cms/pages/components/dashboard/layout/topbar.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ const Topbar = styled.div`
1111
align-items: center;
1212
border-bottom: ${({ theme }) => theme.border.thin};
1313
@media screen and (max-width: 450px) {
14-
padding: 17px 10px;
14+
flex-direction: column;
15+
height: 140px;
16+
padding: 17px 5px;
1517
}
1618
`
1719

packages/cms/pages/resources/resource-form/field-group.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ const FieldGroupWrapper = styled.div<{
99
transition: all 0.25s ease-in-out;
1010
border-left: ${({ theme, focused }) =>
1111
`3px solid ${focused ? theme.colors.primary : theme.border.color}`};
12+
13+
@media only screen and (max-width: 767px) {
14+
padding-left: 5px;
15+
}
1216
`
1317

1418
interface FieldGroupProps {

packages/cms/pages/resources/resource-form/resource-form.tsx

+35-4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ const SidebarCollapseExpandIcon = styled.button<{ close: boolean }>`
4949
left: ${({ close }) => (close ? '-60px' : '-14px')};
5050
z-index: 99;
5151
background-color: ${({ theme }) => theme.colors.ghost};
52+
53+
@media only screen and (max-width: 767px) {
54+
top: 5px;
55+
}
5256
`
5357

5458
const Title = styled.button`
@@ -201,24 +205,45 @@ const PublishAndSaveToDraftContainer = styled.div`
201205
gap: 0.75rem;
202206
display: flex;
203207
align-items: center;
208+
209+
@media only screen and (max-width: 450px) {
210+
width: 100%;
211+
justify-content: space-evenly;
212+
}
204213
`
205214
const TitleAndBackButtonContainer = styled.div`
206215
gap: 0.75rem;
207216
display: flex;
208217
align-items: center;
218+
219+
@media only screen and (max-width: 450px) {
220+
width: 100%;
221+
justify-content: space-around;
222+
margin-right: 30px;
223+
}
209224
`
210225
const PageWrapper = styled.div`
211226
width: 100%;
212227
height: 100%;
213228
overflow-y: auto;
214229
padding: 40px;
230+
231+
@media screen and (max-width: 450px) {
232+
overflow-x: hidden;
233+
}
215234
`
216235
const PageContent = styled.div`
217236
// width: 50%;
218237
width: 650px;
219238
margin: 0px auto;
220239
`
221240

241+
const ResourceTitle = styled(EuiTitle)`
242+
@media screen and (max-width: 450px) {
243+
font-size: 14px;
244+
}
245+
`
246+
222247
export function resolveDefaultFormValues(
223248
resource: ResourceContract,
224249
data: AbstractData,
@@ -358,11 +383,11 @@ export const ResourceFormView: React.FunctionComponent<{
358383
>
359384
Back
360385
</EuiButtonEmpty>
361-
<EuiTitle size="xs">
386+
<ResourceTitle size="xs">
362387
<h3>
363388
{isEditing ? 'Edit' : 'Create'} {resource?.name?.toLowerCase()}
364389
</h3>
365-
</EuiTitle>
390+
</ResourceTitle>
366391
</TitleAndBackButtonContainer>
367392
<PublishAndSaveToDraftContainer>
368393
<EuiButton fill>Save as draft</EuiButton>
@@ -457,6 +482,12 @@ export function useCreateResourceForm({
457482
}
458483
}
459484

485+
const ResourceFormRow = styled(EuiFormRow)`
486+
@media only screen and (max-width: 767px) {
487+
width: 70vw;
488+
}
489+
`
490+
460491
export const ResourceForm: React.FunctionComponent<{
461492
isEditing?: boolean
462493
createResourceForm: ReturnType<typeof useCreateResourceForm>
@@ -511,7 +542,7 @@ export const ResourceForm: React.FunctionComponent<{
511542
key={field.inputName}
512543
focused={activeField?.inputName === field.inputName}
513544
>
514-
<EuiFormRow
545+
<ResourceFormRow
515546
fullWidth
516547
label={field.label || field.name}
517548
helpText={field.description}
@@ -539,7 +570,7 @@ export const ResourceForm: React.FunctionComponent<{
539570
setValue(field.inputName, value)
540571
}}
541572
/>
542-
</EuiFormRow>
573+
</ResourceFormRow>
543574
</FieldGroup>
544575
)
545576
})}

0 commit comments

Comments
 (0)