Files
bruno/packages/bruno-app/src/components/Environments/EnvironmentSelector/StyledWrapper.js
Mathieu DREANO 5a6714f085 feat(#304) Environments color 🎨 (#1053)
* associate environment to a color

Signed-off-by: mathieu <mathieu.dreano@gmail.com>

use StyledWrapper

Signed-off-by: mathieu <mathieu.dreano@gmail.com>

don't save anything for color if it is not set

Signed-off-by: mathieu <mathieu.dreano@gmail.com>

use redux store instead of local state

remove logs

fix selectedEnvironment

cleanup

add bottom border on active tab

* associate environment to a color

Signed-off-by: mathieu <mathieu.dreano@gmail.com>

* move dependency to appropriate package.json

Signed-off-by: mathieu <mathieu.dreano@gmail.com>

* use border instead of background color

Signed-off-by: mathieu <mathieu.dreano@gmail.com>

* simplify onColorChange

Signed-off-by: mathieu <mathieu.dreano@gmail.com>

* add black, keep backgound on unselected color

Signed-off-by: mathieu <mathieu.dreano@gmail.com>

* fix conflicts

Signed-off-by: mathieu <mathieu.dreano@gmail.com>

* associate environment to a color

Signed-off-by: mathieu <mathieu.dreano@gmail.com>

use StyledWrapper

Signed-off-by: mathieu <mathieu.dreano@gmail.com>

don't save anything for color if it is not set

Signed-off-by: mathieu <mathieu.dreano@gmail.com>

use redux store instead of local state

remove logs

fix selectedEnvironment

cleanup

add bottom border on active tab

# Conflicts:
#	packages/bruno-app/src/components/Environments/EnvironmentSelector/StyledWrapper.js
#	packages/bruno-app/src/components/Environments/EnvironmentSelector/index.js
#	packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/index.js
#	packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/index.js
#	packages/bruno-app/src/components/Environments/EnvironmentSettings/index.js
#	packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js

* Update packages/bruno-app/src/components/Environments/EnvironmentSettings/EnvironmentList/EnvironmentDetails/EnvironmentColor/index.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* unused selectedEnvironment prop in EnvironmentList

Signed-off-by: Mathieu D <mathieu.dreano@decathlon.com>

* RequestTab, avoid unnecessary call if undefined activeCollection

Signed-off-by: Mathieu D <mathieu.dreano@decathlon.com>

* use @uiw/reac-color instead of react-color

Signed-off-by: Mathieu D <mathieu.dreano@decathlon.com>

---------

Signed-off-by: mathieu <mathieu.dreano@gmail.com>
Signed-off-by: Mathieu D <mathieu.dreano@decathlon.com>
Co-authored-by: Mathieu D <mathieu.dreano@decathlon.com>
Co-authored-by: Anoop M D <anoop@usebruno.com>
Co-authored-by: Mathieu DREANO <122891400+mdreano@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2026-01-30 17:07:13 +05:30

250 lines
6.3 KiB
JavaScript

import styled from 'styled-components';
const Wrapper = styled.div`
.current-environment {
border-radius: ${(props) => props.theme.border.radius.base};
padding: 0.25rem 0.3rem 0.25rem 0.5rem;
user-select: none;
background-color: ${(props) => props.color ? undefined : 'transparent'};
border: 2px solid ${(props) => props.color ?? props.theme.dropdown.selectedColor};
line-height: 1rem;
transition: all 0.15s ease;
&:hover {
border-color: ${(props) => props.theme.app.collection.toolbar.environmentSelector.hoverBorder};
background-color: ${(props) => props.theme.app.collection.toolbar.environmentSelector.hoverBg};
}
.active-env-toolhint {
display: flex;
flex-direction: row;
}
.caret {
margin-left: 0.25rem;
color: ${(props) => props.theme.app.collection.toolbar.environmentSelector.caret};
fill: ${(props) => props.theme.app.collection.toolbar.environmentSelector.caret};
align-self: center;
}
.env-icon {
margin-right: 0.25rem;
color: ${(props) => props.color ?? props.theme.dropdown.selectedColor};
}
.env-text {
color: ${(props) => props.color ?? props.theme.dropdown.selectedColor};
font-size: ${(props) => props.theme.font.size.base};
display: block;
}
.env-separator {
color: ${(props) => props.theme.app.collection.toolbar.environmentSelector.separator};
margin: 0 0.35rem;
}
.env-text-inactive {
color: ${(props) => props.theme.colors.text.muted};
font-size: ${(props) => props.theme.font.size.sm};
}
&.no-environments {
color: ${(props) => props.theme.app.collection.toolbar.environmentSelector.noEnvironment.text};
background-color: ${(props) => props.theme.app.collection.toolbar.environmentSelector.noEnvironment.bg};
border: 1px dashed ${(props) => props.theme.app.collection.toolbar.environmentSelector.noEnvironment.border};
&:hover {
border-color: ${(props) => props.theme.app.collection.toolbar.environmentSelector.noEnvironment.hoverBorder};
background-color: ${(props) => props.theme.app.collection.toolbar.environmentSelector.noEnvironment.hoverBg};
}
}
}
.tippy-box {
width: ${(props) => props.width}px;
min-width: 12rem;
max-width: 650px !important;
min-height: 15.5rem;
max-height: 75vh;
font-size: ${(props) => props.theme.font.size.base};
position: relative;
overflow: hidden;
}
.tippy-box .tippy-content {
padding: 0;
display: flex;
flex-direction: column;
height: 100%;
.dropdown-item {
display: flex;
flex-direction: row;
align-items: center;
column-gap: 0.35em;
padding: 0.35rem 0.6rem;
cursor: pointer;
font-size: ${(props) => props.theme.font.size.base};
color: ${(props) => props.theme.dropdown.primaryText};
&:hover:not(:disabled) {
background-color: ${(props) => props.theme.dropdown.hoverBg};
}
&.active {
background-color: ${(props) => props.theme.dropdown.selectedBg};
color: ${(props) => props.color ?? props.theme.dropdown.selectedColor} !important;
}
&.no-environment {
color: ${(props) => props.theme.dropdown.mutedText};
}
}
}
.configure-button {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: ${(props) => props.theme.dropdown.bg};
border-top: 0.0625rem solid ${(props) => props.theme.dropdown.separator};
z-index: 10;
margin: 0;
&:hover {
background-color: ${(props) => props.theme.dropdown.bg + ' !important'};
}
button {
color: ${(props) => props.theme.text};
display: flex;
align-items: center;
justify-content: center;
width: 100%;
gap: 0.5rem;
}
}
.tab-button {
color: ${(props) => props.theme.colors.text.subtext0};
font-size: ${(props) => props.theme.font.size.sm};
.tab-content-wrapper {
position: relative;
display: flex;
align-items: center;
gap: 0.125rem;
}
&.active {
color: ${(props) => props.theme.tabs.active.color};
border-bottom-color: ${(props) => props.theme.tabs.active.border};
}
&.inactive {
border-bottom-color: transparent;
}
}
.tab-content {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
}
.environment-list {
flex: 1;
overflow-y: auto;
max-height: calc(75vh - 8rem);
padding-bottom: 2.625rem;
}
.dropdown-item-list {
max-height: 75vh;
overflow-y: scroll;
}
.empty-state {
max-width: 20rem;
margin: 0 auto;
padding: 0.35rem 0.6rem;
text-align: center;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 12.5rem;
h3 {
color: ${(props) => props.theme.text};
font-size: 1rem;
font-weight: 500;
margin-bottom: 0.5rem;
line-height: 1.4;
}
p {
color: ${(props) => props.theme.text};
opacity: 0.75;
font-size: ${(props) => props.theme.font.size.xs};
line-height: 1.5;
margin-bottom: 1rem;
max-width: 11.875rem;
margin: 0 auto;
margin-bottom: 1rem;
}
.space-y-2 {
width: 100%;
align-self: stretch;
}
.space-y-2 > button {
border: 0.0625rem solid ${(props) => props.theme.text};
background: transparent;
color: ${(props) => props.theme.text};
padding: 0.5rem 1rem;
border-radius: 0.375rem;
width: 100%;
margin-bottom: 0.5rem;
font-size: ${(props) => props.theme.font.size.sm};
font-weight: 500;
display: flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
&:hover {
background-color: ${(props) => props.theme.dropdown.hoverBg};
}
&:last-child {
margin-bottom: 0;
}
}
}
.no-collection-message {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 2rem 1rem;
color: ${(props) => props.theme.text};
font-size: ${(props) => props.theme.font.size.base};
line-height: 1.5;
text-align: center;
opacity: 0.75;
svg {
margin: 0 auto 1rem auto;
color: ${(props) => props.theme.text};
opacity: 0.5;
}
}
`;
export default Wrapper;