Refactored InputGroup style and tokens

pull/6537/head
Cagatay Civici 2024-10-05 22:33:50 +03:00
parent c3b6af0140
commit fb969c2638
5 changed files with 55 additions and 73 deletions

View File

@ -1,26 +1,7 @@
import BaseStyle from '@primevue/core/base/style';
const theme = ({ dt }) => `
.p-inputgroup {
display: flex;
align-items: stretch;
width: 100%;
}
.p-inputgroupaddon {
display: flex;
align-items: center;
justify-content: center;
padding: 0.5rem;
background: ${dt('inputgroup.addon.background')};
color: ${dt('inputgroup.addon.color')};
border-top: 1px solid ${dt('inputgroup.addon.border.color')};
border-left: 1px solid ${dt('inputgroup.addon.border.color')};
border-bottom: 1px solid ${dt('inputgroup.addon.border.color')};
padding: 0.5rem 0.75rem;
min-width: 2.5rem;
}
.p-inputgroup,
.p-inputgroup .p-floatlabel,
.p-inputgroup .p-iftalabel {
display: flex;
@ -29,83 +10,76 @@ const theme = ({ dt }) => `
}
.p-inputgroup .p-inputtext,
.p-inputgroup-fluid .p-inputtext,
.p-inputgroup .p-inputwrapper,
.p-inputgroup-fluid .p-input {
.p-inputgroup .p-inputwrapper {
flex: 1 1 auto;
width: 1%;
}
.p-inputgroupaddon {
display: flex;
align-items: center;
justify-content: center;
padding: ${dt('inputgroup.addon.padding')};
background: ${dt('inputgroup.addon.background')};
color: ${dt('inputgroup.addon.color')};
border-top: 1px solid ${dt('inputgroup.addon.border.color')};
border-bottom: 1px solid ${dt('inputgroup.addon.border.color')};
min-width: ${dt('inputgroup.addon.min.width')};
}
.p-inputgroupaddon:first-child,
.p-inputgroupaddon + .p-inputgroupaddon {
border-left: 1px solid ${dt('inputgroup.addon.border.color')};
}
.p-inputgroupaddon:last-child {
border-right: 1px solid ${dt('inputgroup.addon.border.color')};
}
.p-inputgroup > .p-component,
.p-inputgroup > .p-inputwrapper > .p-inputtext,
.p-inputgroup > .p-inputwrapper > .p-component,
.p-inputgroup > .p-floatlabel > .p-component,
.p-inputgroup > .p-iftalabel > .p-component {
.p-inputgroup > .p-floatlabel > .p-inputwrapper > .p-component,
.p-inputgroup > .p-iftalabel > .p-component,
.p-inputgroup > .p-iftalabel > .p-inputwrapper > .p-component {
border-radius: 0;
margin: 0;
}
.p-inputgroup > .p-component + .p-inputgroupaddon,
.p-inputgroup > .p-inputwrapper > .p-inputtext + .p-inputgroupaddon,
.p-inputgroup > .p-floatlabel > .p-component + .p-inputgroupaddon,
.p-inputgroup > .p-iftalabel > .p-component + .p-inputgroupaddon {
border-left: 0 none;
}
.p-inputgroup > .p-component:focus,
.p-inputgroup > .p-inputwrapper > .p-inputtext:focus,
.p-inputgroup > .p-floatlabel > .p-component:focus,
.p-inputgroup > .p-iftalabel > .p-component:focus {
z-index: 1;
}
.p-inputgroup > .p-component:focus ~ label,
.p-inputgroup > .p-inputwrapper > .p-inputtext:focus~label,
.p-inputgroup > .p-floatlabel > .p-component:focus~label,
.p-inputgroup > .p-iftalabel > .p-component:focus~label {
z-index: 1;
}
.p-inputgroupaddon:first-child,
.p-inputgroup button:first-child,
.p-inputgroup input:first-child,
.p-inputgroup > .p-inputwrapper:first-child,
.p-inputgroup > .p-inputwrapper:first-child > .p-inputtext {
border-top-left-radius: ${dt('inputgroup.addon.border.radius')};
border-bottom-left-radius: ${dt('inputgroup.addon.border.radius')};
}
.p-inputgroup .p-floatlabel:first-child input,
.p-inputgroup .p-iftalabel:first-child input {
.p-inputgroup > .p-component:first-child,
.p-inputgroup > .p-inputwrapper:first-child > .p-component,
.p-inputgroup > .p-floatlabel:first-child > .p-component,
.p-inputgroup > .p-floatlabel:first-child > .p-inputwrapper > .p-component,
.p-inputgroup > .p-iftalabel:first-child > .p-component,
.p-inputgroup > .p-iftalabel:first-child > .p-inputwrapper > .p-component {
border-top-left-radius: ${dt('inputgroup.addon.border.radius')};
border-bottom-left-radius: ${dt('inputgroup.addon.border.radius')};
}
.p-inputgroupaddon:last-child,
.p-inputgroup button:last-child,
.p-inputgroup input:last-child,
.p-inputgroup > .p-inputwrapper:last-child,
.p-inputgroup > .p-inputwrapper:last-child > .p-inputtext {
.p-inputgroup > .p-component:last-child,
.p-inputgroup > .p-inputwrapper:last-child > .p-component,
.p-inputgroup > .p-floatlabel:last-child > .p-component,
.p-inputgroup > .p-floatlabel:last-child > .p-inputwrapper > .p-component,
.p-inputgroup > .p-iftalabel:last-child > .p-component,
.p-inputgroup > .p-iftalabel:last-child > .p-inputwrapper > .p-component {
border-top-right-radius: ${dt('inputgroup.addon.border.radius')};
border-bottom-right-radius: ${dt('inputgroup.addon.border.radius')};
}
.p-inputgroup .p-floatlabel:last-child input,
.p-inputgroup .p-iftalabel:last-child input {
border-top-right-radius: ${dt('inputgroup.addon.border.radius')};
border-bottom-right-radius: ${dt('inputgroup.addon.border.radius')};
.p-inputgroup .p-component:focus,
.p-inputgroup .p-component.p-focus,
.p-inputgroup .p-inputwrapper-focus,
.p-inputgroup .p-component:focus ~ label,
.p-inputgroup .p-component.p-focus ~ label,
.p-inputgroup .p-inputwrapper-focus ~ label {
z-index: 1;
}
.p-inputgroup-fluid .p-button {
.p-inputgroup > .p-button:not(.p-button-icon-only) {
width: auto;
}
.p-inputgroup-fluid .p-button.p-button-icon-only {
width: 2.5rem;
}
`;
const classes = {

View File

@ -3,6 +3,8 @@ export default {
background: '{form.field.background}',
borderColor: '{form.field.border.color}',
color: '{form.field.icon.color}',
borderRadius: '{form.field.border.radius}'
borderRadius: '{form.field.border.radius}',
padding: '0.5rem',
minWidth: '2.5rem'
}
};

View File

@ -1,6 +1,8 @@
export default {
addon: {
borderRadius: '{form.field.border.radius}'
borderRadius: '{form.field.border.radius}',
padding: '0.625rem 0.5rem',
minWidth: '2.75rem'
},
colorScheme: {
light: {

View File

@ -3,6 +3,8 @@ export default {
background: '{form.field.background}',
borderColor: '{form.field.border.color}',
color: '{form.field.icon.color}',
borderRadius: '{form.field.border.radius}'
borderRadius: '{form.field.border.radius}',
padding: '0.75rem',
minWidth: '3rem'
}
};

View File

@ -3,6 +3,8 @@ export default {
background: '{form.field.background}',
borderColor: '{form.field.border.color}',
color: '{form.field.icon.color}',
borderRadius: '{form.field.border.radius}'
borderRadius: '{form.field.border.radius}',
padding: '0.5rem',
minWidth: '2.5rem'
}
};