Page MenuHomePhabricator

Add Codex to Toolforge cdnjs
Closed, ResolvedPublicFeature

Description

Feature summary:
Codex should be available in the Toolforge CDNjs Mirror.

Use case(s):
Easily use the Codex design system in tools. (It is possible to use Codex without it being in CDNjs, but it’s not as comfortable having to install it into www/static/ manually.)

Benefits:
Example tool: Wikidata Image Positions currently uses some WikibaseMediaInfo components through unholy ResourceLoader hacks – it would be much better to use Codex there.


This will almost certainly end in a pull request to cdnjs upstream, but maybe we can coordinate or discuss a bit here first.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Here are two draft JSON files for cdnjs/packages:

codex.json
{
  "name": "codex",
  "filename": "codex.umd.js",
  "description": "Codex design system for Wikimedia",
  "keywords": [
    "codex",
    "design-system",
    "components",
    "front-end"
  ],
  "autoupdate": {
    "source": "npm",
    "target": "@wikimedia/codex",
    "fileMap": [
      {
        "basePath": "dist",
        "files": [
          "*.@(js|mjs|css)"
        ]
      }
    ]
  },
  "repository": {
    "type": "git",
    "url": "git+https://gerrit.wikimedia.org/r/design/codex.git"
  },
  "authors": [
    {
      "name": "Wikimedia Foundation Design Systems Team",
      "url": "https://www.mediawiki.org/wiki/Design_Systems_Team"
    }
  ],
  "license": "GPL-2.0-or-later"
}
codex-icons.json
{
  "name": "codex-icons",
  "filename": "codex-icons.umd.js",
  "description": "icons of the Codex design system for Wikimedia",
  "keywords": [
    "codex",
    "design-system",
    "components",
    "front-end"
  ],
  "autoupdate": {
    "source": "npm",
    "target": "@wikimedia/codex-icons",
    "fileMap": [
      {
        "basePath": "dist",
        "files": [
          "*.@(js|mjs|json|svg)"
        ]
      }
    ]
  },
  "repository": {
    "type": "git",
    "url": "git+https://gerrit.wikimedia.org/r/design/codex.git"
  },
  "authors": [
    {
      "name": "Wikimedia Foundation Design Systems Team",
      "url": "https://www.mediawiki.org/wiki/Design_Systems_Team"
    }
  ],
  "license": "MIT"
}

Some questions I can think of:

  • any more keywords that should be added?
  • any additional authors that should be credited? (they can also have an email field)
  • should codex-design-tokens also be published? (not sure that one’s as useful on CDNjs, which to me implies you’re not using a build system – but perhaps the .css file can still be used?)

The cdnjs mirror really is a mirror of the upstream https://cdnjs.com/ project. We do not currently inject any local content into the system. https://github.com/cdnjs/packages/blob/master/CONTRIBUTING.md describes how to add new content to the upstream project.

If CDNjs can be configured to automatically pull in the latest version on NPM (which is our primary target when we release new versions) then I think it's fine for us to do this.

We're getting ready to do a Codex 1.0 release (not sure when exactly but likely some time in the next couple of months). Maybe this would be a good point to add Codex to CDNjs.

As far as which packages to add, I'd suggest we just add everything (with the exception of the MW-specific codex-search package) – so codex, codex-icons, and codex-design-tokens. The design tokens are also available as CSS variables which could be used without a build-step.

If CDNjs can be configured to automatically pull in the latest version on NPM (which is our primary target when we release new versions) then I think it's fine for us to do this.

Yes, it updates from npm automatically.

We're getting ready to do a Codex 1.0 release (not sure when exactly but likely some time in the next couple of months). Maybe this would be a good point to add Codex to CDNjs.

Sure; does that mean you want to wait until then?

As far as which packages to add, I'd suggest we just add everything (with the exception of the MW-specific codex-search package) – so codex, codex-icons, and codex-design-tokens. The design tokens are also available as CSS variables which could be used without a build-step.

Fair enough. Here’s a JSON file for the design tokens then (I picked theme-wikimedia-ui.css as the main entry point):

codex-design-tokens.json
{
  "name": "codex-design-tokens",
  "filename": "theme-wikimedia-ui.css",
  "description": "design tokens of the Codex design system for Wikimedia",
  "keywords": [
    "codex",
    "design-system",
    "components",
    "front-end"
  ],
  "autoupdate": {
    "source": "npm",
    "target": "@wikimedia/codex-design-tokens",
    "fileMap": [
      {
        "basePath": "dist",
        "files": [
          "*.@(css|json)"
        ]
      }
    ]
  },
  "repository": {
    "type": "git",
    "url": "git+https://gerrit.wikimedia.org/r/design/codex.git"
  },
  "authors": [
    {
      "name": "Wikimedia Foundation Design Systems Team",
      "url": "https://www.mediawiki.org/wiki/Design_Systems_Team"
    }
  ],
  "license": "MIT"
}

We're getting ready to do a Codex 1.0 release (not sure when exactly but likely some time in the next couple of months). Maybe this would be a good point to add Codex to CDNjs.

Sure; does that mean you want to wait until then?

Yes, we would likely wait until after the 1.0 release if we were to do this ourselves. Alternatively, if you're familiar with cdnjs, you're welcome to add it yourself before then.

CCiufo-WMF added a project: Codex 1.0.
CCiufo-WMF moved this task from Backlog to Codex Adoption on the Codex board.
CCiufo-WMF moved this task from Backlog to Follow Up on the Codex 1.0 board.
CCiufo-WMF moved this task from Inbox to Backlog on the Design-System-Team board.

Done at https://github.com/cdnjs/packages/pull/1589.

Here’s a JSON file for the design tokens then (I picked theme-wikimedia-ui.css as the main entry point):

Last-second correction: the design tokens are GPL-2.0-or-later like codex, not MIT like codex-icons.

LucasWerkmeister claimed this task.

Done – here’s a small example file:

<!doctype html>
<html lang="en">
  <head>
    <link rel="stylesheet" href="https://tools-static.wmflabs.org/cdnjs/ajax/libs/codex/0.6.2/codex.style.css">
    <link rel="stylesheet" href="https://tools-static.wmflabs.org/cdnjs/ajax/libs/codex-design-tokens/0.6.2/theme-wikimedia-ui.css">
    <script type="importmap">
      {
          "imports": {
              "vue": "https://tools-static.wmflabs.org/cdnjs/ajax/libs/vue/3.3.4/vue.esm-browser.min.js",
              "codex": "https://tools-static.wmflabs.org/cdnjs/ajax/libs/codex/0.6.2/codex.mjs"
          }
      }
    </script>
    <script type="module">
      import { createApp } from 'vue';
      import { CdxButton } from 'codex';
      createApp ( {
          template: `
            <CdxButton
              action="progressive"
              type="primary"
              @click="count++"
            >
              You clicked me {{ count }} times :)
            </CdxButton>
          `,
          components: { CdxButton },
          data() {
              return { count: 0 };
          },
      } ).mount( window.main );
      </script>
    <style>
      body {
          height: 100vh;
          display: flex;
          align-items: center;
          justify-content: center;
          background: var( --background-color-notice--framed );
      }
    </style>
  </head>
  <body>
    <main id="main">
    </main>
  </body>
</html>

@LucasWerkmeister I think this work and outcome is worthy of an email to wikitech-l or at least the cloud mailing list to increase discoverability for folks. Thanks for doing it!

After successfully using Codex in Wikidata Image Positions (commit), I’ve now sent an email to wikitech-l and cloud-l :)

@LucasWerkmeister Great stuff! For Tech News timing, do you think we should
(A) include it immediately (either in this upcoming edition written today/tomorrow, or the following week's edition),
(B) postpone until some kind of onwiki documentation page is available (if planned),
(C) postpone until v.1.0 (given the "couple of months" mentioned above) ?

If immediately, do you have any suggestions on how to summarize the entry? I'm not sure if the caveats need to be directly mentioned. E.g. A very basic entry could be something like:

Tool developers can now use user interface components from Codex, the design system for Wikimedia, directly via the Toolforge CDNjs mirror. [ 1 ]

I'm not certain if those are the correct details to include from your email. Suggestions/draft-rewrites appreciated!

Sorry, I completely forgot to reply to this. Given my tardiness – I suppose option C, and then we can fold it into a general entry for the Codex release? I’m thinking something like:

Version 1.0 of Codex, the design system for Wikimedia, has been published. It can be used by gadget or user script developers via the TODO ResourceLoader module (TODO docs link?), and by tool developers via the Toolforge CDNjs mirror (announcement).

That draft and plan looks good to me! I'll leave it to you to (create/delegate creating) the docs, and to either add the entry to Tech News when it is time to do so, or update this task or ping me here/somewhere to let me know. Thanks!

Pppery subscribed.

This has clearly missed the mark for being reasonably announced in Tech News over a year and a half after the original change.

I believe we were still waiting for the sub-task to be resolved, of writing documentation on how to use it. I will move the draft-summary and tag over to that task.