Busca por patterns e indexação de tags de patterns
This commit is contained in:
1 parent
34a44ec763
commit
a582ac2925
2 files changed
+470
-22
No files matched your search
+66
-22
@@ -149,35 +149,79 @@ title: "{{ page.file }}"
|
||||
</span>
|
||||
|
||||
{% comment %}
|
||||
>>> INÍCIO DA LÓGICA DE STEPS MELHORADA <<<
|
||||
Container da grade de steps
|
||||
>>> INÍCIO DA LÓGICA DE STEPS CLICÁVEIS (4-steps) <<<
|
||||
(O container agora é 'row' para manter os chunks na horizontal)
|
||||
{% endcomment %}
|
||||
<div style="display: flex; flex-direction: row; border: 1px solid #ccc; padding: 2px; border-radius: 2px; background-color: #f0f0f0;">
|
||||
{% for step_active in pattern_steps %}
|
||||
<div class="patterns-container" style="display: flex; flex-direction: row; flex-wrap: wrap; gap: 4px;">
|
||||
{% assign total_steps = pattern_steps.size %}
|
||||
{% assign chunk_size = 4 %}
|
||||
|
||||
{% comment %} Calcula quantos pedaços de 4 steps teremos {% endcomment %}
|
||||
{% assign num_chunks = total_steps | divided_by: chunk_size %}
|
||||
|
||||
{% comment %}
|
||||
FIX: Primeiro calculamos o 'resto' e salvamos numa variável
|
||||
{% endcomment %}
|
||||
{% assign remainder = total_steps | modulo: chunk_size %}
|
||||
|
||||
{% comment %}
|
||||
FIX: Agora sim usamos a variável na comparação
|
||||
{% endcomment %}
|
||||
{% if remainder > 0 %}
|
||||
{% assign num_chunks = num_chunks | plus: 1 %}
|
||||
{% endif %}
|
||||
|
||||
{% for i in (0..num_chunks) %}
|
||||
{% assign start_index = i | times: chunk_size %}
|
||||
|
||||
{% comment %} Define a cor do step {% endcomment %}
|
||||
{% assign step_color = '#d9d9d9' %} {% comment %} Cor INATIVA (cinza claro) {% endcomment %}
|
||||
{% if step_active == true or step_active == 'true' or step_active == 1 %}
|
||||
{% assign step_color = '#4caf50' %} {% comment %} Cor ATIVA (verde) {% endcomment %}
|
||||
{% endif %}
|
||||
|
||||
{% comment %} Define o espaçamento (divisão do compasso) {% endcomment %}
|
||||
{% assign step_style = '' %}
|
||||
{% assign step_index_zero_based = forloop.index0 %}
|
||||
{% comment %} Pega a fatia de 4 steps {% endcomment %}
|
||||
{% assign current_chunk_array = pattern_steps | slice: start_index, chunk_size %}
|
||||
|
||||
{% comment %} --- Calcula o módulo *antes* do 'if' --- {% endcomment %}
|
||||
{% assign remainder = step_index_zero_based | modulo: 4 %}
|
||||
{% if current_chunk_array.size > 0 %}
|
||||
|
||||
{% comment %} 1. Serializa o chunk (ex: [1,0,0,1] -> "1001") {% endcomment %}
|
||||
{% assign chunk_string = "" %}
|
||||
{% for step in current_chunk_array %}
|
||||
{% if step == true or step == 'true' or step == 1 %}
|
||||
{% assign chunk_string = chunk_string | append: '1' %}
|
||||
{% else %}
|
||||
{% assign chunk_string = chunk_string | append: '0' %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if step_index_zero_based > 0 and remainder == 0 %}
|
||||
{% assign step_style = 'margin-left: 3px;' %}
|
||||
{% endif %}
|
||||
{% comment %}
|
||||
2. Cria o link clicável
|
||||
{% endcomment %}
|
||||
{% assign search_url = '/pattern/?p=' | append: chunk_string | relative_url %}
|
||||
|
||||
<a href="{{ search_url }}" title="Buscar padrão {{ chunk_string }}" style="display: inline-block;">
|
||||
|
||||
{% comment %} 3. Renderiza o visual do step DENTRO do link {% endcomment %}
|
||||
<div style="display: flex; flex-direction: row; border: 1px solid #999; padding: 2px; border-radius: 2px; background-color: #f0f0f0;">
|
||||
|
||||
{% for step_active in current_chunk_array %}
|
||||
{% assign step_color = '#d9d9d9' %}
|
||||
{% if step_active == true or step_active == 'true' or step_active == 1 %}
|
||||
{% assign step_color = '#4caf50' %}
|
||||
{% endif %}
|
||||
|
||||
<div style="width: 5px; height: 10px; background-color: {{ step_color }}; border-radius: 1px; margin-right: 1px;"></div>
|
||||
{% endfor %}
|
||||
|
||||
<div
|
||||
style="width: 5px; height: 10px; background-color: {{ step_color }}; border-radius: 1px; {{ step_style }}"
|
||||
></div>
|
||||
{% comment %} Preenche com steps vazios se o chunk for menor que 4 {% endcomment %}
|
||||
{% assign remaining_steps = chunk_size | minus: current_chunk_array.size %}
|
||||
{% if remaining_steps > 0 %}
|
||||
{% for j in (1..remaining_steps) %}
|
||||
<div style="width: 5px; height: 10px; background-color: #d9d9d9; border-radius: 1px; margin-right: 1px;"></div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% comment %} >>> FIM DA LÓGICA DE STEPS MELHORADA <<< {% endcomment %}
|
||||
{% comment %} >>> FIM DA LÓGICA DE STEPS CLICÁVEIS <<< {% endcomment %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
Reference in new issue
Block a user