Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for important CSS rules #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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: 1 addition & 0 deletions src/devtools/client/inspector/computed/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export async function createComputedProperties(
stylesheet,
stylesheetURL,
overridden: !!property.overridden,
priority: property.priority,
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export default function ComputedProperty(props: ComputedPropertyProps) {
<div className="matchedselectors">
{isExpanded
? property.selectors.map((selector, index) => (
// Reproduction step Repro:ComputedProperty:
<MatchedSelector key={index} selector={selector} />
))
: null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default function MatchedSelector(props: MatchedSelectorProps) {
colorSwatchClassName="computed-colorswatch"
fontFamilySpanClassName="computed-font-family"
values={selector.parsedValue}
priority={selector.priority}
/>
</div>
</span>
Expand Down
1 change: 1 addition & 0 deletions src/devtools/client/inspector/computed/state/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface MatchedSelectorState {
overridden: boolean;
stylesheet: string;
stylesheetURL: string;
priority?: string;
}

export interface ComputedState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ interface DeclarationValueProps {
colorSwatchClassName: string;
fontFamilySpanClassName: string;
values: (string | Record<string, string>)[];
priority?: string;
}

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

return value;
});

// Add the !important suffix if priority is "important"
if (this.props.priority === "important") {
renderedValues.push(" !important");
}

return renderedValues;
}
}

Expand Down
Loading