Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion frontend/scripts/generate-tokens.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,6 @@ function generateUtilities() {

// Colour utilities
const colourMappings = {
border: { prefix: 'border', property: 'border-color' },
icon: { prefix: 'icon', property: null }, // special: color + fill
surface: { prefix: 'bg-surface', property: 'background-color' },
text: { prefix: 'text', property: 'color' },
Expand Down
14 changes: 9 additions & 5 deletions frontend/web/components/ValueEditor/ValueEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export interface ValueEditorProps {
// A string, not FlagsmithValue: deciding that "123" is a number is the
// caller's job (Utils.getTypedValue, Utils.valueToFeatureState).
onChange?: (value: string) => void
// Not editable, but shown at full strength, unlike `disabled`.
readOnly?: boolean
value?: FlagsmithValue
}

Expand All @@ -47,6 +49,7 @@ const ValueEditor: FC<ValueEditorProps> = ({
language: languageProp,
onBlur,
onChange,
readOnly,
value,
}) => {
const [picked, setPicked] = useState<ValueEditorLanguage>()
Expand Down Expand Up @@ -75,7 +78,8 @@ const ValueEditor: FC<ValueEditorProps> = ({

// A caller that pins the format has nothing to switch, so the row goes, and
// copy goes with it as it always has.
const showControls = !disabled && !languageProp
const locked = disabled || readOnly
const showControls = !locked && !languageProp

// Only rendered alongside the format row, so a pinned caller does not need a
// DOMParser run on every keystroke.
Expand Down Expand Up @@ -117,10 +121,10 @@ const ValueEditor: FC<ValueEditorProps> = ({

<Highlight
aria-labelledby={label ? labelId : undefined}
aria-readonly={disabled || undefined}
disabled={disabled}
onChange={disabled ? null : onChange}
onBlur={disabled ? null : onBlur}
aria-readonly={locked || undefined}
disabled={locked}
onChange={locked ? null : onChange}
onBlur={locked ? null : onBlur}
role='textbox'
className={language}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { AddVariationButton } from 'components/mv/AddVariationButton'
import ErrorMessage from 'components/ErrorMessage'
import InfoMessage from 'components/InfoMessage'
import WarningMessage from 'components/WarningMessage'
import Banner from 'components/base/Banner'
import Tooltip from 'components/Tooltip'
import Icon from 'components/icons/Icon'
import Switch from 'components/Switch'
Expand Down Expand Up @@ -471,9 +472,9 @@ const FeatureValueTab: FC<FeatureValueTabProps> = ({
<WarningMessage warningMessage="This identity override contains a value that is not one of this flag's variations. We recommend changing it." />
)}
{!!divergedVariantOverride && (
<WarningMessage
warningMessage={`This identity is served a stale copy of variation '${divergedVariantOverride.key}', taken when the override was saved. Press Update Feature to refresh it.`}
/>
<Banner type='warning' className='mb-3'>
{`This identity is served a stale copy of variation '${divergedVariantOverride.key}', taken when the override was saved. Press Update Feature to refresh it.`}
</Banner>
)}
<VariationOptions
canCreateFeature={false}
Expand Down
14 changes: 6 additions & 8 deletions frontend/web/components/mv/VariationOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,17 @@ export const VariationOptions: FC<VariationOptionsProps> = ({
{/* No radio, unlike the row below: selecting it would save the stale
value as a literal override. */}
{select && !!divergedOverride && (
<div className='border border-warning bg-surface-warning rounded p-3 mb-2'>
<div className='border border-warning rounded p-3 mb-2'>
<div className='mb-2'>
<span className='h6 mb-0 font-weight-semibold text-warning'>
Currently served
</span>
</div>
<div className='border border-warning rounded p-3'>
<ValueEditor
label={divergedOverride.key}
disabled
value={Utils.getTypedValue(divergedOverride.servedValue)}
/>
</div>
<ValueEditor
label={divergedOverride.key}
readOnly
value={Utils.getTypedValue(divergedOverride.servedValue)}
/>
</div>
)}
{select && !!unmatchedOverride && (
Expand Down
26 changes: 20 additions & 6 deletions frontend/web/styles/3rdParty/_bootstrap.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,26 @@ $_color-util: map-merge(
);
$utilities: map-merge($utilities, ("color": $_color-util));

// Border colour: token border utilities take over. Values are identical to
// Bootstrap's, so a no-op; it just moves ownership to the token layer.
// Border colour: Bootstrap generates `.border-*` with the token colours, after
// `.border`, so `border border-warning` draws the warning colour.
$_border-util: map-get($utilities, "border-color");
$_border-util: map-merge(
$_border-util,
(values: map-remove(map-get($_border-util, "values"), "danger", "info", "success", "warning"))
(
values: map-merge(
map-get($_border-util, "values"),
(
"action": var(--color-border-action),
"danger": var(--color-border-danger),
"default": var(--color-border-default),
"disabled": var(--color-border-disabled),
"info": var(--color-border-info),
"strong": var(--color-border-strong),
"success": var(--color-border-success),
"warning": var(--color-border-warning),
)
),
)
);
$utilities: map-merge($utilities, ("border-color": $_border-util));

Expand Down Expand Up @@ -104,8 +118,8 @@ $utilities: map-merge($utilities, ("shadow": $_shadow-util));
padding: 0;
}

// Bootstrap's `.border*` utilities paint `--bs-border-color` with `!important`,
// so `.border-default` can never win. Point the Bootstrap variable at the token.
:root {
// The colour of a plain `.border`. On body, not :root, so the token resolves
// under .dark too.
body {
--bs-border-color: var(--color-border-default);
}
10 changes: 0 additions & 10 deletions frontend/web/styles/_token-utilities.scss

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading