|
| 1 | +.. _apis: |
| 2 | + |
| 3 | +============ |
| 4 | +API projects |
| 5 | +============ |
| 6 | + |
| 7 | +Many of the Maykin projects are API-first projects with only a minimum of "public |
| 8 | +frontend" requirements. maykin-common facilitates these by providing some base |
| 9 | +templates, CSS and JS for the landing page. |
| 10 | + |
| 11 | +Templates |
| 12 | +========= |
| 13 | + |
| 14 | +Two templates are provided from the library that you should extend: |
| 15 | + |
| 16 | +* ``maykin_common/api/index_base.html``, use it in ``index.html`` for your landing page |
| 17 | +* ``maykin_common/api/includes/footer.html``, use it to extend your |
| 18 | + ``includes/footer.html`` from |
| 19 | + |
| 20 | +You'll need to make some modifications to the root ``urls.py`` and ``master.html`` to |
| 21 | +wire up everything automatically. |
| 22 | + |
| 23 | +.. tip:: With the default project setup, the necessary CSS and Javascript are |
| 24 | + automatically loaded. If you use another master template, make sure to define the |
| 25 | + ``view_class``, ``extra_css`` and ``content`` blocks to override. |
| 26 | + |
| 27 | +``maykin_common/api/index_base.html`` |
| 28 | +------------------------------------- |
| 29 | + |
| 30 | +Provides the general scaffolding of the language page with the tabbed layout for |
| 31 | +Dutch and English content and the general branding. |
| 32 | + |
| 33 | +In your child template, make sure to override the blocks that are specific to your |
| 34 | +project: |
| 35 | + |
| 36 | +* ``page_title`` |
| 37 | +* ``page_subtitle`` |
| 38 | +* ``content_nl`` |
| 39 | +* ``content_en`` |
| 40 | +* ``license_link`` |
| 41 | + |
| 42 | +``maykin_common/api/includes/footer.html`` |
| 43 | +------------------------------------------ |
| 44 | + |
| 45 | +Provides the standard footer layout with sensible defaults. You can override (default) |
| 46 | +values by clever usage of the ``with`` tag: |
| 47 | + |
| 48 | +.. code-block:: django |
| 49 | +
|
| 50 | + {% block footer %} |
| 51 | + {% capture as issues_link silent %}<a class="link link--muted" href="https://github.com/maykinmedia/awesome-project/issues">issues</a>{% endcapture %} |
| 52 | +
|
| 53 | + {% with issues_link=issues_link %} |
| 54 | + {{ block.super }} |
| 55 | + {% endwith %} |
| 56 | +
|
| 57 | + {% endblock %} |
| 58 | +
|
| 59 | +.. tip:: Consider installing django-capture-tag for cleaner templates, like the example |
| 60 | + above. |
| 61 | + |
| 62 | +Blocks you'll typically want to override are: |
| 63 | + |
| 64 | +* ``footer`` |
| 65 | +* ``links`` - the middle column with project-specific links |
| 66 | + |
| 67 | +Other blocks you can override are: |
| 68 | + |
| 69 | +* ``other_links`` - the links in the rightmost column |
| 70 | + |
| 71 | +Stylesheets |
| 72 | +=========== |
| 73 | + |
| 74 | +The base template automatically loads the ``maykin_common/css/api.css`` stylesheets |
| 75 | +which contains the majority of the styles for the landing page components. |
| 76 | + |
| 77 | +.. note:: While the default template uses font-awesome class names, the font-awesome |
| 78 | + stylesheet is **not** included as we want to avoid any frontend toolchains as long |
| 79 | + as possible. You have to make sure your project includes the styles and font assets |
| 80 | + yourself. |
| 81 | + |
| 82 | +.. tip:: No default values are provided, however the default-project template does |
| 83 | + provide a starter setup in the ``_os_api`` directory. |
| 84 | + |
| 85 | +The CSS is written with theming in mind. At the time of writing, the following CSS |
| 86 | +variables are supported, grouped by component: |
| 87 | + |
| 88 | +**Page title** |
| 89 | + |
| 90 | +* ``--page-title-color`` |
| 91 | +* ``--page-title-font-family`` |
| 92 | + |
| 93 | +**Footer** |
| 94 | + |
| 95 | +* ``--footer-border-color`` |
| 96 | + |
| 97 | +**Tabs** |
| 98 | + |
| 99 | +* ``--tabs-border-color`` |
| 100 | +* ``--tabs-item-color`` |
| 101 | +* ``--tabs-item-hover-color`` |
| 102 | +* ``--tabs-item-hover-border-color`` |
| 103 | + |
| 104 | +**Button** |
| 105 | + |
| 106 | +* ``--button-color`` |
| 107 | +* ``--button-background-color`` |
| 108 | +* ``--button-hover-background-color`` |
| 109 | +* ``--button-alert-background-color`` |
| 110 | +* ``--button-alert-hover-background-color`` |
| 111 | + |
| 112 | +**Link** |
| 113 | + |
| 114 | +* ``--link-color`` |
| 115 | +* ``--link-color-hover`` |
| 116 | +* ``--link-color-muted`` |
| 117 | + |
| 118 | +Javascript |
| 119 | +========== |
| 120 | + |
| 121 | +We ship a minimal amount of Javascript and it's automatically loaded from the base |
| 122 | +template. |
| 123 | + |
| 124 | +``maykin_common/js/nav-tabs.js`` |
| 125 | +-------------------------------- |
| 126 | + |
| 127 | +Controls the (active) tab state for the ``.tabs`` component. |
0 commit comments