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

Installed tailwind, added components page, created toy components with django-components and embedded Vue #4800

Open
wants to merge 3 commits 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 cl/assets/static-global/css/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import "tailwindcss";
6 changes: 5 additions & 1 deletion cl/assets/templates/base.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load static %}{% load humanize %}{% load widget_tweaks %}{% load extras %}{% load waffle_tags %}
{% load static tailwind_tags %}{% load humanize %}{% load widget_tweaks %}{% load extras %}{% load waffle_tags %}
<!DOCTYPE html>
<html lang="en">
<head>
Expand Down Expand Up @@ -54,6 +54,10 @@

<link href="{% static "css/font-awesome.css" %}" rel="stylesheet">

<link href="{% static "css/app.css" %}" rel="stylesheet">
{% tailwind_css %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm finding this a bit weird. We link to app.css, which imports tailwindcss. Gotta be a better way. I think Bots.law just has:

  {% tailwind_preload_css %}
  {% tailwind_css %}

Honestly not sure what the preload vs. regular do, but definitely simpler/cleaner?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly not sure what the preload vs. regular do

According to the documentation, the {% tailwind_css %} tag generates a stylesheet link for the app that has all the tailwind assets. This is the only step required to include Tailwind CSS on a page. The preload tag generates a preload directive for the stylesheet, which improves loading performance in production.

<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We never rely on a CDN this way. We have our own and it's more secure not to trust others. I think it'd probably also fail our CSP rules (but not sure).

{% block privacy %}
{% if private %}
<meta name="robots" content="noindex, noodp, noarchive, noimageindex" />
Expand Down
9 changes: 9 additions & 0 deletions cl/components/date.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django_components.component import Component, register


@register("date")
class Date(Component):
template = "<div class='date-component rounded-lg border border-gray-200 flex items-center px-4 py-2'>Today's date is {{ date }}</div>"

def get_context_data(self, date):
return {"date": date}
Loading
Loading