Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

get_css_data with css in the component #1474

Open
@KingRotiv

Description

@KingRotiv

I'm trying to pass variables from the component to my CSS, but I'm not receiving the values. Am I doing something wrong, or is this a bug? I've tried changing the variable name and other solutions, but nothing works. At first, I thought this would only work if the CSS was in a separate file, but the documentation has examples of using this function with embedded CSS.

Code:

@register(f"{app_name}:detalhe_conteudo")classConteudoDetalhe(Component):template:types.django_html="""        {% load component_tags %}        <div>            <div>                {% component "portal:card_conteudo_detalhe"                    conteudo=conteudo                %}                {% endcomponent %}            </div>            <div>                <h1>{{ conteudo.titulo_brasil }}</h1>                <p><strong>Título Original:</strong> {{ conteudo.titulo_original }}</p>                {% if not TIPO_LIVRO and not TIPO_CANAL_TV %}                <p><strong>Data de Lançamento:</strong> {{ conteudo.data_lancamento }}</p>                <p><strong>Classificação Indicativa:</strong> {{ conteudo.classificacao_indicativa|default:"N/A" }}</p>                {% endif %}                <p><strong>Gêneros:</strong>                    {% for genero in conteudo.generos.all %}                        <a href="{% url urlname_conteudos_por_genero pk=genero.pk %}">                            #{{ genero.nome }}                        </a>                        {% if not forloop.last %}|{% endif %}                    {% empty %}                        N/A                    {% endfor %}                </p>                <p><strong>Sinopse:</strong> {{ conteudo.sinopse }}</p>            </div>        </div>        {% slot "extras" required / %}    """css:types.css="""        main {            background: linear-gradient(                to bottom,                var(--corhex) 0%,                rgba(14, 14, 14, 0.8) 60%,                rgba(14, 14, 14, 1) 100%            );        }        @media (max-width: 575.98px) {            .col-card-conteudo-detalhe {                width: 200px;            }        }    """defget_template_data(self,args:Any,kwargs:Any,slots:Any,context:Context    )->Mapping:conteudo=kwargs["conteudo"]urlname_conteudos_por_genero=conteudo.url_portal.urlname_conteudos_por_generoreturn {"conteudo":conteudo,"TIPO_LIVRO":isinstance(conteudo,Livro),"TIPO_CANAL_TV":isinstance(conteudo,CanalTV),"urlname_conteudos_por_genero":urlname_conteudos_por_genero,        }defget_css_data(self,args:Any,kwargs:Any,slots:Any,context:Context    )->Mapping:conteudo=kwargs["conteudo"]return {"corhex":conteudo.cor_dominante_hex}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp