Skip to content

Commit

Permalink
Display matched selector priority (#10609)
Browse files Browse the repository at this point in the history
* Display matched selector priority

* Include priority as a separate property of `MatchedSelectorState`

* fixed things
  • Loading branch information
Andarist authored Jul 11, 2024
1 parent d6f9492 commit 4cc1d67
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/devtools/client/inspector/computed/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export async function createComputedProperties(
selectors.push({
value: property.value,
parsedValue,
priority: property.priority,
selector,
stylesheet,
stylesheetURL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default function MatchedSelector(props: MatchedSelectorProps) {
colorSpanClassName="computed-color"
colorSwatchClassName="computed-colorswatch"
fontFamilySpanClassName="computed-font-family"
priority={selector.priority}
values={selector.parsedValue}
/>
</div>
Expand Down
3 changes: 3 additions & 0 deletions src/devtools/client/inspector/computed/state/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Priority } from "../../rules/models/text-property";

export interface ComputedPropertyState {
name: string;
value: string;
Expand All @@ -9,6 +11,7 @@ export interface MatchedSelectorState {
selector: string;
value: string;
parsedValue: any[];
priority: Priority;
overridden: boolean;
stylesheet: string;
stylesheetURL: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react";

import { COLOR, FONT_FAMILY, URI } from "third-party/css/output-parser";

import { Priority } from "../models/text-property";
import Color from "./value/Color";
import FontFamily from "./value/FontFamily";
import Url from "./value/Url";
Expand All @@ -10,12 +11,13 @@ interface DeclarationValueProps {
colorSpanClassName: string;
colorSwatchClassName: string;
fontFamilySpanClassName: string;
priority?: Priority;
values: (string | Record<string, string>)[];
}

class DeclarationValue extends React.PureComponent<DeclarationValueProps> {
render() {
return this.props.values.map(v => {
const values = this.props.values.map(v => {
if (typeof v === "string") {
return v;
}
Expand Down Expand Up @@ -46,6 +48,13 @@ class DeclarationValue extends React.PureComponent<DeclarationValueProps> {

return value;
});

return (
<>
{values}
{this.props.priority ? ` !${this.props.priority}` : null}
</>
);
}
}

Expand Down

0 comments on commit 4cc1d67

Please sign in to comment.