202410291423.0.0 • Published 8 months ago

@biggive/components v202410291423.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Built With Stencil

Big Give StencilJS Web Components

The project is based on a sample project from https://stenciljs.com/docs/getting-started

Setup and Build

Get latest version of codebase from github

git clone https://github.com/thebiggive/components.git
cd components

Install StencilJS dependencies as defined in package.json

Set FONTAWESOME_NPM_AUTH_TOKEN in your environment so pro packages can be installed, and:

npm install
npm start

Run tests

npm test

Development

Follow Stencil + repository conventions

CI runs lint checks, but there are tools to help you follow the expected code style so you don't have to fix it later.

In Visual Studio Code, you might find this ESLint extension and this Prettier one helpful.

We use both tools to ensure both consistent code style and adherence to Stencil recommended practice.

Husky should also set you up a pre-commit hook that fixes anything it can automatically, and complains about anything else. If you don't appear to have this and had already installed packages before this feature was set up, run npm install again.

Dependencies and build output

Anything externally managed should be loaded with npm and no copies checked into this codebase. We can use Stencil copy tasks and target app build strategies to get things in the right place.

Generated build outputs should similarly be .gitignored.

Because Stencil components have partly generated readme docs, after changing any @Props or similar it's necessary to npm run build before committing your changes. The docs are source controlled as they can include manual content. CircleCI will also run npm run build and fail if there are any changes required that were not committed.

If you make a new one, it's a good idea to add a one line description of its purpose to the readme before the generated section.

Output targets

Stencil is able to take an app's source and compile it to numerous targets

Read more in Stencil's docs.

Primary targets are:

  • angularOutputTarget() – used in Donate frontend.
  • dist-custom-elements – the docs don't make this terribly clear but with our current configuration, these are a dependency for the Angular project/target to build successfully. Angular needs to be told that they live inside dist/ (so are published in dist/components).
  • dist-hydrate-script for SSR – used in Donate frontend as initially served by ECS. Stencil document this one separately.
  • dist for general web modules – used in WordPress.
  • Storybook has its own build step using the component from source. Currently, this is also used in Salesforce to embed components in iframes, the only feasible way we've been able to get Experiences to dynamically pull in components.
  • docs-readme for documentation.

Targets we have but just for local experiments:

  • www

Angular components

As well as the core package @biggive/components, CI automatically publishes a version best tailored to Angular as @biggive/components-angular. The former are possible to load into Angular but the latter will work better as documented.

Our Angular workspace and library are set up as per that documentation, but our Stencil library lives in this repo's root, one directory up from in the docs' structure. So far this seems to have no adverse effects.

Asset dependencies

So far our strategy has been to avoid separate file assets where this is an out-the-box option, but to choose copying over more complex build time changes (e.g. base-64-inlining images) otherwise. This is to get the simplest working proof of concept up quickly and we may revisit it soon.

For now:

  • FontAwesome uses pure SVGs and not fonts. This seems to work well and I suspect is the best option for performance, component interoperability, simplicity and licence compliance.
  • The Euclid font is copied with a Stencil copy task and available in the dist output's assets/fonts. An Angular app's build, for example, can then use the style with the following addition to an angular.json "styles" key: "node_modules/@biggive/components/dist/biggive/assets/fonts/EuclidTriangle/stylesheet.css"
  • Images are also copied with a Stencil copy task, and fixed references use getAssetPath() plus a path, e.g. getAssetPath('/assets/images/banner.png'). See the Stencil asset docs for more on this. Angular seems to be able to use this without setAssetPath() if we config its "assets" key to put files in the same folder as the app's own images. This is the approach taken on this proof of concept branch. Should we find managing image assets messy in apps generally, an alternative approach we might try is importing images to component style and adding @rollup/plugin-image to Stencil's build config. Or if there are only a few, we could also investigate whether assetsDirs on a @Component folds in what's needed in a way that works in Angular et al.

Make any required changes to the sample web components

The web components are configured in /src/components

The /src/index.html file can be used as a test area for displaying the web components in a static HTML page.

Run the StencilJS build command to package your changes

npm run build

Outputs

dist directory - https://stenciljs.com/docs/distribution

This directory contains the distribtion files

www directory - https://stenciljs.com/docs/www

This directory contains a static version of the web components which can be used for testing and inclusion in simple web apps. Due to CORS restrictions, the index.html file needs to be run from a webserver (not as a local file).

Storybook

We've followed this guide to provide sample usage of key components: a living style guide.

From the main branch, CI automatically npm-publishes a new major version and updates the Storybook preview.

For now, the local npm run storybook won't load static image assets or fonts. We've prioritised realistic renders in the deployed environment, where these work due to:

  • CI separately copying the main build's assets output to S3: see e.g. deploy-staging-storybook in CI config
  • Storybook having a custom preview-head.html.

Publish to NPM

Versions and publishing

CircleCI will now create a new version, build and publish it to npm on every commit to main. Version numbers are generated such that every release is a new "major" release, so dependent packages must use version "*" to automatically receive new versions on npm update.

Manual updates

It is no longer expected to manually update versions, but if the automatic process is ever broken, the steps used before Jan '23 were:

  • Update the root package.json's version field.
  • npm install to update package-lock.json to match.
  • Update angular/projects/components/package.json's version field so that @biggive/components-angular matches too.
  • git tag v0.0.1 (replace with your new version)
  • git push --tags

You can also do the npm publish manually if necessary:

First, connect to npm if you have never done so before: npm add_user.

Then:

npm publish --access=public

The name of the NPM package and version number can be updated in the root package.json file. It's currently set to (@biggive/components, 0.0.1)

More information about publishing and distribution is available at https://stenciljs.com/docs/distribution

Include components in web app

Include the following script tag in the HTML head

<script type='module' src='https://unpkg.com/@biggive/components@0.0.1/dist/biggive/biggive.esm.js'></script>

Include the markup for the sample web component

<demo-campaign-cards></demo-campaign-cards>

Styled Component

The first styled components are available

  • biggive-grid
  • biggive-campaign-card

These can be added to an HTML page with the following code:

  <biggive-grid>

    <biggive-campaign-card
      banner="/assets/images/banner.png"
      days-remaining={50}
      target={50000}
      organisation-name="Ardent Theatre Company"
      campaign-type="Match Funded"
      campaign-title="Strike! A play by Tracy Ryan"
      categories="Arts/Culture/Heritage|Environment/Conservation|Health/Wellbeing"
      beneficiaries="General Public/Humankind"
      match-funds-remaining={17424}
      total-funds-raised={15424}
      call-to-action-url="#"
      call-to-action-label="Donate"
    />

  </biggive-grid>
202410281750.0.0

8 months ago

202410291423.0.0

8 months ago

202410251514.0.0

8 months ago

202410291301.0.0

8 months ago

202410231414.0.0

8 months ago

202410250825.0.0

8 months ago

202410231512.0.0

8 months ago

202410230910.0.0

8 months ago

202410231625.0.0

8 months ago

202410231038.0.0

8 months ago

202410231009.0.0

8 months ago

202410221637.0.0

8 months ago

202410221555.0.0

8 months ago

202410221727.0.0

8 months ago

202410161136.0.0

8 months ago

202410181207.0.0

8 months ago

202410171010.0.0

8 months ago

202410151606.0.0

8 months ago

202410031015.0.0

8 months ago

202410090941.0.0

8 months ago

202410140844.0.0

8 months ago

202410041110.0.0

8 months ago

202409251201.0.0

9 months ago

202409260214.0.0

9 months ago

202410110800.0.0

8 months ago

202410101746.0.0

8 months ago

202410101754.0.0

8 months ago

202409131619.0.0

9 months ago

202408291508.0.0

10 months ago

202408301428.0.0

10 months ago

202408301142.0.0

10 months ago

202409131555.0.0

9 months ago

202409030852.0.0

9 months ago

202409161527.0.0

9 months ago

202409181001.0.0

9 months ago

202409131625.0.0

9 months ago

202409030845.0.0

9 months ago

202408161522.0.0

10 months ago

202406271159.0.0

12 months ago

202408060913.0.0

10 months ago

202408211745.0.0

10 months ago

202406211002.0.0

12 months ago

202408060829.0.0

10 months ago

202407011358.0.0

12 months ago

202407010959.0.0

12 months ago

202408221605.0.0

10 months ago

202408221527.0.0

10 months ago

202407051353.0.0

11 months ago

202406211443.0.0

12 months ago

202408161527.0.0

10 months ago

202406281731.0.0

12 months ago

202407011202.0.0

12 months ago

202312071742.0.0

2 years ago

202312041141.0.0

2 years ago

202312031231.0.0

2 years ago

202311241148.0.0

2 years ago

202311240945.0.0

2 years ago

202308250924.0.0

2 years ago

202308161206.0.0

2 years ago

202308161033.0.0

2 years ago

202309180924.0.0

2 years ago

202311211130.0.0

2 years ago

202307100703.0.0

2 years ago

202307100729.0.0

2 years ago

202310301020.0.0

2 years ago

202308101557.0.0

2 years ago

202310310929.0.0

2 years ago

202309211700.0.0

2 years ago

202307091949.0.0

2 years ago

202308101621.0.0

2 years ago

202309061001.0.0

2 years ago

202311211421.0.0

2 years ago

202308161134.0.0

2 years ago

202311061800.0.0

2 years ago

202308161105.0.0

2 years ago

202308111427.0.0

2 years ago

202309210829.0.0

2 years ago

202307271726.0.0

2 years ago

202309141628.0.0

2 years ago

202309200915.0.0

2 years ago

202307190919.0.0

2 years ago

202308161015.0.0

2 years ago

202308161158.0.0

2 years ago

202307091858.0.0

2 years ago

202307100721.0.0

2 years ago

202308161124.0.0

2 years ago

202311211120.0.0

2 years ago

202307100656.0.0

2 years ago

202310310925.0.0

2 years ago

202308171555.0.0

2 years ago

202309141604.0.0

2 years ago

202307171427.0.0

2 years ago

202308311526.0.0

2 years ago

202308221410.0.0

2 years ago

202307051615.0.0

2 years ago

202309281045.0.0

2 years ago

202311211301.0.0

2 years ago

202308151517.0.0

2 years ago

202307200905.0.0

2 years ago

202308181645.0.0

2 years ago

202309180958.0.0

2 years ago

202308161118.0.0

2 years ago

202311201334.0.0

2 years ago

202308161146.0.0

2 years ago

202309260920.0.0

2 years ago

202308241036.0.0

2 years ago

202309201242.0.0

2 years ago

202309191556.0.0

2 years ago

202308141050.0.0

2 years ago

202308021605.0.0

2 years ago

202308101705.0.0

2 years ago

202307191013.0.0

2 years ago

202309151020.0.0

2 years ago

202308171208.0.0

2 years ago

202308180939.0.0

2 years ago

202311091230.0.0

2 years ago

202307102042.0.0

2 years ago

202311211133.0.0

2 years ago

202308111157.0.0

2 years ago

202308180855.0.0

2 years ago

202309011438.0.0

2 years ago

202307271559.0.0

2 years ago

202307191002.0.0

2 years ago

202308161137.0.0

2 years ago

202307201413.0.0

2 years ago

202307100646.0.0

2 years ago

202309271411.0.0

2 years ago

202309141649.0.0

2 years ago

202309040952.0.0

2 years ago

202306210851.0.0

2 years ago

202305040926.0.0

2 years ago

202305241149.0.0

2 years ago

202305301947.0.0

2 years ago

202305230804.0.0

2 years ago

202305101345.0.0

2 years ago

202305171609.0.0

2 years ago

202305111528.0.0

2 years ago

202305161606.0.0

2 years ago

202304111006.0.0

2 years ago

202304251558.0.0

2 years ago

202304281233.0.0

2 years ago

202304111314.0.0

2 years ago

202304111046.0.0

2 years ago

202302161725.0.0

2 years ago

202303301223.0.0

2 years ago

202303231047.0.0

2 years ago

202302161138.0.0

2 years ago

202303201542.0.0

2 years ago

202303201257.0.0

2 years ago

202302161705.0.0

2 years ago

202304041024.0.0

2 years ago

202303031447.0.0

2 years ago

202303171305.0.0

2 years ago

202302151016.0.0

2 years ago

202303061752.0.0

2 years ago

202303021718.0.0

2 years ago

202303201125.0.0

2 years ago

202303031057.0.0

2 years ago

202303171653.0.0

2 years ago

202302141635.0.0

2 years ago

202303031121.0.0

2 years ago

202303171148.0.0

2 years ago

202302161145.0.0

2 years ago

202303171502.0.0

2 years ago

202303171614.0.0

2 years ago

202304051358.0.0

2 years ago

202301271119.0.0

2 years ago

202301261048.0.0

2 years ago

202301261005.0.0

2 years ago

202302031402.0.0

2 years ago

202301201544.0.0

2 years ago

202301261059.0.0

2 years ago

202301241512.0.0

2 years ago

202301201119.0.0

2 years ago

202302031045.0.0

2 years ago

202301201542.0.0

2 years ago

1.0.187

2 years ago

202301311640.0.0

2 years ago

1.0.186

2 years ago

1.0.189

2 years ago

1.0.188

2 years ago

1.0.185

2 years ago

202301201539.0.0

2 years ago

202301201113.0.0

2 years ago

202301201128.0.0

2 years ago

1.0.198

2 years ago

1.0.197

2 years ago

1.0.199

2 years ago

1.0.194

2 years ago

1.0.193

2 years ago

1.0.196

2 years ago

1.0.195

2 years ago

202302010657.0.0

2 years ago

202301201101.0.0

2 years ago

1.0.190

2 years ago

1.0.192

2 years ago

1.0.191

2 years ago

1.0.143

3 years ago

1.0.142

3 years ago

1.0.145

3 years ago

1.0.144

3 years ago

1.0.141

3 years ago

1.0.140

3 years ago

1.0.147

3 years ago

1.0.146

3 years ago

1.0.149

3 years ago

1.0.148

3 years ago

1.0.132

3 years ago

1.0.131

3 years ago

1.0.134

3 years ago

1.0.133

3 years ago

1.0.130

3 years ago

1.0.139

3 years ago

1.0.136

3 years ago

1.0.135

3 years ago

1.0.138

3 years ago

1.0.137

3 years ago

1.0.165

3 years ago

1.0.167

3 years ago

1.0.166

3 years ago

1.0.161

3 years ago

1.0.160

3 years ago

1.0.163

3 years ago

1.0.162

3 years ago

1.0.169

3 years ago

1.0.168

3 years ago

1.0.154

3 years ago

1.0.153

3 years ago

1.0.156

3 years ago

1.0.150

3 years ago

1.0.152

3 years ago

1.0.151

3 years ago

1.0.158

3 years ago

1.0.157

3 years ago

1.0.159

3 years ago

1.0.1

3 years ago

1.0.101

3 years ago

1.0.100

3 years ago

1.0.183

2 years ago

1.0.182

2 years ago

1.0.184

2 years ago

1.0.107

3 years ago

1.0.106

3 years ago

1.0.9

3 years ago

1.0.109

3 years ago

1.0.8

3 years ago

1.0.108

3 years ago

1.0.7

3 years ago

1.0.103

3 years ago

1.0.6

3 years ago

1.0.102

3 years ago

1.0.5

3 years ago

1.0.105

3 years ago

1.0.4

3 years ago

1.0.104

3 years ago

1.0.3

3 years ago

1.0.181

3 years ago

1.0.180

3 years ago

1.0.176

3 years ago

1.0.175

3 years ago

1.0.178

3 years ago

1.0.177

3 years ago

1.0.172

3 years ago

1.0.171

3 years ago

1.0.174

3 years ago

1.0.173

3 years ago

1.0.179

3 years ago

1.0.170

3 years ago

1.0.121

3 years ago

1.0.120

3 years ago

1.0.123

3 years ago

1.0.122

3 years ago

0.0.23

3 years ago

0.0.25

3 years ago

1.0.129

3 years ago

1.0.128

3 years ago

1.0.125

3 years ago

1.0.124

3 years ago

1.0.127

3 years ago

1.0.126

3 years ago

1.0.82

3 years ago

1.0.81

3 years ago

1.0.110

3 years ago

1.0.112

3 years ago

1.0.111

3 years ago

1.0.118

3 years ago

1.0.117

3 years ago

1.0.119

3 years ago

1.0.114

3 years ago

1.0.113

3 years ago

1.0.116

3 years ago

1.0.115

3 years ago

1.0.91

3 years ago

1.0.95

3 years ago

1.0.93

3 years ago

1.0.92

3 years ago

1.0.99

3 years ago

1.0.98

3 years ago

1.0.97

3 years ago

1.0.96

3 years ago

0.0.21

3 years ago

0.0.20

3 years ago

0.0.18

3 years ago

0.0.17

3 years ago

0.0.16

3 years ago

0.0.15

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago