Skip to content

Commit

Permalink
chore: fix 'replaced by' rule list (#16007)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjermanovic committed Jun 17, 2022
1 parent c1d0240 commit f6e2e63
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 10 deletions.
3 changes: 3 additions & 0 deletions docs/src/_includes/components/rule-list.macro.html
@@ -0,0 +1,3 @@
{%- macro ruleList(params) -%}
{% for rule in params.rules %}<a href="{{ ['/rules/', rule] | join | url }}" class="rule-list-item"><code>{{ rule }}</code></a>{% endfor %}
{%- endmacro -%}
6 changes: 4 additions & 2 deletions docs/src/_includes/components/rule.macro.html
@@ -1,3 +1,5 @@
{% from 'components/rule-list.macro.html' import ruleList %}

{%- macro rule(params) -%}
<article class="rule {% if params.deprecated == true %}rule--deprecated{% endif %} {% if params.removed == true %}rule--removed{% endif %}">
<div class="rule__content">
Expand All @@ -7,7 +9,7 @@
<span class="rule__status">deprecated</span>
</p>
{%- if params.replacedBy|length -%}
<p class="rule__description">Replaced by <a href="{{ ['/rules/', params.replacedBy] | join | url }}"><code>{{ params.replacedBy }}</code></a></p>
<p class="rule__description">Replaced by {{ ruleList({ rules: params.replacedBy }) }}</p>
{%- else -%}<p class="rule__description">{{ params.description }}</p>
{%- endif -%}
{%- elseif params.removed == true -%}
Expand All @@ -16,7 +18,7 @@
<span class="rule__status">removed</span>
</p>
{%- if params.replacedBy -%}
<p class="rule__description">Replaced by <a href="{{ ['/rules/', params.replacedBy] | join | url }}"><code>{{ params.replacedBy }}</code></a></p>
<p class="rule__description">Replaced by {{ ruleList({ rules: params.replacedBy }) }}</p>
{%- else -%}<p class="rule__description">{{ params.description }}</p>
{%- endif -%}
{%- else -%}
Expand Down
23 changes: 15 additions & 8 deletions docs/src/assets/scss/components/rules.scss
Expand Up @@ -67,6 +67,14 @@
font-size: .875rem;
margin-bottom: .25rem;
margin-block-end: .25rem;
}

a.rule__name {
text-decoration: none;

&:hover {
text-decoration: underline;
}

&::after {
position: absolute;
Expand All @@ -80,14 +88,6 @@
}
}

a.rule__name {
text-decoration: none;

&:hover {
text-decoration: underline;
}
}

.rule__description {
font-size: var(--step--1);
}
Expand Down Expand Up @@ -166,3 +166,10 @@ a.rule__name {
}
}
}

a.rule-list-item+a.rule-list-item::before {
content: ",";
display: inline-block;
margin-left: 5px;
margin-right: 5px;
}
25 changes: 25 additions & 0 deletions docs/src/library/rule-list.md
@@ -0,0 +1,25 @@
---
title: Rule list
---

The rule list is a macro defined in `components/rule-list.macro.html`. The macro accepts a list of rule names and renders comma-separated links.

## Usage

{% raw %}

```html
<!-- import the macro -->
{% from 'components/rule-list.macro.html' import ruleList %}

<!-- use the macro -->
{{ ruleList({ rules: ['accessor-pairs', 'no-undef'] }) }}
```

{% endraw %}

## Examples

{% from 'components/rule-list.macro.html' import ruleList %}

{{ ruleList({ rules: ['accessor-pairs', 'no-undef'] }) }}

0 comments on commit f6e2e63

Please sign in to comment.