-
Notifications
You must be signed in to change notification settings - Fork 23.2k
link parameters property & param() function #44852
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
Merged
Merged
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
439132e
added example of using dashed-ident in env()
dletorey f4c789d
added svg syntax and env options
dletorey 9c7d02a
added param and link-parameters pages
dletorey 6a49022
Merge branch 'main' into 44466-link-parameters
dletorey 74d76d3
completed the param() page
dletorey e5bb337
corrected the spelling of example
dletorey d407685
completed the link-parameters css property page
dletorey c1147fd
Update files/en-us/web/css/reference/properties/link-parameters/index.md
dletorey f269da9
Update files/en-us/web/css/reference/properties/link-parameters/index.md
dletorey bfb3af2
Update files/en-us/web/css/reference/values/dashed-ident/index.md
dletorey b54657c
Update files/en-us/web/css/reference/values/param/index.md
dletorey 911174b
Merge branch 'main' into 44466-link-parameters
dletorey 6a34115
added nolint to make syntax more readable
dletorey bbe236e
removed nolint from svg block
dletorey ec0f447
compressed the svg files
dletorey ec58a69
Merge branch 'main' into 44466-link-parameters
dletorey 82a8815
Update files/en-us/web/css/reference/properties/link-parameters/index.md
dletorey a0e9e76
Update files/en-us/web/css/reference/values/env/index.md
dletorey f37941b
Update files/en-us/web/css/reference/values/dashed-ident/index.md
dletorey e3f10e7
Update files/en-us/web/css/reference/values/param/index.md
dletorey eebb058
Merge branch 'main' into 44466-link-parameters
dletorey 3134c85
Merge branch 'main' into 44466-link-parameters
dletorey 7e60330
Use more consistent alts
pepelsbey b410279
Make prettier happy
pepelsbey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
files/en-us/web/css/reference/properties/link-parameters/index.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| --- | ||
| title: "`link-parameters` CSS property" | ||
| short-title: link-parameters | ||
| slug: Web/CSS/Reference/Properties/link-parameters | ||
| page-type: css-property | ||
| browser-compat: css.properties.link-parameters | ||
| sidebar: cssref | ||
| --- | ||
|
|
||
| The **`link-parameters`** [CSS](/en-US/docs/Web/CSS) property sets values of external resources, such as SVGs, whose attributes have been set with the {{cssxref("env")}} CSS function | ||
|
|
||
| ## Syntax | ||
|
|
||
| ```css-nolint | ||
| /* single value */ | ||
| link-parameters: param(--color, red); | ||
|
|
||
| /* multiple values */ | ||
| link-parameters: | ||
| param(--color1, red), | ||
| param(--color2, blue), | ||
| param(--color3, green); | ||
| ``` | ||
|
|
||
| ## Values | ||
|
|
||
| - `none` | ||
| - : No link parameters are specified. | ||
|
|
||
| - {{cssxref("param")}} | ||
| - : A list of one or more link parameters. | ||
|
|
||
| ## Formal definition | ||
|
|
||
| {{CSSInfo}} | ||
|
|
||
| ## Example | ||
|
|
||
| ### Updating the colors of an external SVG file | ||
|
|
||
| In this example the original SVG, on the left, is a square with `stroke` attribute set with `env(--color1, chartreuse)` and `fill` attribute set with `env(--color2, darkgreen)`. The `link-parameters` property is used to update both of these attributes on the updated square, on the right, with multiple {{cssxref("param")}} CSS functions. | ||
|
|
||
| ```html | ||
| <div class="squares"> | ||
| <img class="original" src="square.svg" alt="A square with a chartreuse border and a dark green fill." /> | ||
| <img class="updated" src="square.svg" alt="A square with a red border and a tomato fill." /> | ||
| </div> | ||
| ``` | ||
|
|
||
| ```css hidden | ||
| .squares { | ||
| height: 200px; | ||
| display: flex; | ||
| flex-direction: row; | ||
| justify-content: space-between; | ||
| } | ||
| img { | ||
| height: 100%; | ||
| } | ||
| ``` | ||
|
|
||
| ```css-nolint | ||
| .updated { | ||
| link-parameters: | ||
| param(--color1, red), | ||
| param(--color2, tomato); | ||
| } | ||
| ``` | ||
|
|
||
| {{EmbedLiveSample('updating_the_colors_of_an_external_SVG_file', '100%', '210px')}} | ||
|
|
||
| ## Specifications | ||
|
|
||
| {{Specifications}} | ||
|
|
||
| ## Browser compatibility | ||
|
|
||
| {{Compat}} | ||
|
|
||
| ## See also | ||
|
|
||
| - {{cssxref("param")}} | ||
| - {{cssxref("env")}} | ||
1 change: 1 addition & 0 deletions
1
files/en-us/web/css/reference/properties/link-parameters/square.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| --- | ||
| title: "`param()` CSS function" | ||
| short-title: param() | ||
| slug: Web/CSS/Reference/Values/param | ||
| page-type: css-function | ||
| browser-compat: css.types.param | ||
| sidebar: cssref | ||
| --- | ||
|
|
||
| The **`param()`** [CSS](/en-US/docs/Web/CSS) [function](/en-US/docs/Web/CSS/Reference/Values/Functions) is used to set link parameters. This can be done using the {{cssxref("link-parameters")}} CSS function, in the fragment URL of an external resource, or in the [`<url-modifier>`](/en-US/docs/Web/CSS/Reference/Values/url_function#url-modifier) of the `url()` CSS function. | ||
|
|
||
| ## Syntax | ||
|
|
||
| ```css | ||
| /* a single value */ | ||
| param(--color, red); | ||
|
|
||
| /* multiple values */ | ||
| param(--color1, red), | ||
| param(--color2, blue), | ||
| param(--color3, green); | ||
| ``` | ||
|
|
||
| ## Values | ||
|
|
||
| - [`<dashed-ident>`](/en-US/docs/Web/CSS/Reference/Values/dashed-ident) | ||
| - A `<dashed-ident>`is a user defined variable that is used as an identifier in the {{cssxref("env")}} CSS function to update the value. | ||
|
|
||
| - `<declaration_value>` {{optional_inline}} | ||
| - : A `<declaration_value>` is the value of the attribute being updated. If the `<declaration-value>` is omitted, it represents an empty value. | ||
|
|
||
| ## Formal definition | ||
|
|
||
| {{CSSInfo}} | ||
|
|
||
| ## Examples | ||
|
|
||
| All of the following examples use the same SVG file, which has attributes set with {{cssxref("env")}} CSS function. | ||
|
|
||
| ```svg | ||
| <!-- example of the code in the external SVG file --> | ||
| <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> | ||
| <rect | ||
| width="100" | ||
| height="100" | ||
| stroke="env(--color1, chartreuse)" | ||
| stroke-width="10" | ||
| fill="env(--color2, darkgreen)" | ||
| /> | ||
| </svg> | ||
| ``` | ||
|
|
||
| ### Using `link-parameters` property | ||
|
|
||
| In this example the SVG attributes are updated with the {{cssxref("link-parameters")}} CSS property and `param()` function. | ||
|
|
||
| ```html | ||
| <div class="squares"> | ||
| <img class="original" src="square.svg" alt="A square with a chartreuse border and a dark green fill." /> | ||
| <img class="greyscale" src="square.svg" alt="A square with a slate grey border and a light grey fill." /> | ||
| <img class="high-contrast" src="square.svg" alt="A square with a fuchsia border and a yellow fill." /> | ||
|
pepelsbey marked this conversation as resolved.
Outdated
|
||
| </div> | ||
| ``` | ||
|
|
||
| ```css hidden | ||
| .squares { | ||
| height: 200px; | ||
| display: flex; | ||
| flex-direction: row; | ||
| justify-content: space-between; | ||
| } | ||
| img { | ||
| height: 100%; | ||
| } | ||
| ``` | ||
|
|
||
| ```css-nolint | ||
| .greyscale { | ||
| link-parameters: | ||
| param(--color1, slategrey), | ||
| param(--color2, lightgrey); | ||
| &:hover { | ||
| link-parameters: | ||
| param(--color1, lightgrey), | ||
| param(--color2, slategrey); | ||
| } | ||
| } | ||
| .high-contrast { | ||
| link-parameters: | ||
| param(--color1, fuchsia), | ||
| param(--color2, yellow); | ||
| &:hover { | ||
| link-parameters: | ||
| param(--color1, yellow), | ||
| param(--color2, fuchsia); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| {{EmbedLiveSample('using_link-parameters_property', '100%', '210px')}} | ||
|
|
||
| ### Passing `param()` into URL modifier | ||
|
|
||
| In this example the SVG attributes are updated by passing the `param()` function into the URL fragment of the [`src`](/en-US/docs/Web/HTML/Reference/Elements/img#src) attribute of the {{htmlelement("img")}} HTML element. | ||
|
|
||
| ```html-nolint | ||
| <img | ||
| src="square.svg#param(--color1, slategrey)¶m(--color2, lightgrey)" | ||
| alt="A square with a slate grey border and a light grey fill." | ||
| /> | ||
| ``` | ||
|
|
||
| ### Using `param()` with `background-image` property | ||
|
|
||
| In this example the SVG attributes are updated by passing the `param()` function into the {{cssxref("url","url()")}} data type of the {{cssxref("background-image")}} CSS property. | ||
|
|
||
| ```css-nolint | ||
| .foo { | ||
| background-image: url( | ||
| "square.svg" | ||
| param(--color1, slategrey), | ||
| param(--color2, lightgrey) | ||
| ); | ||
| } | ||
| ``` | ||
|
|
||
| ## Specifications | ||
|
|
||
| {{Specifications}} | ||
|
|
||
| ## Browser compatibility | ||
|
|
||
| {{Compat}} | ||
|
|
||
| ## See also | ||
|
|
||
| - {{cssxref("link-parameters")}} | ||
| - {{cssxref("env")}} | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.