202405101333.0.0 • Published 1 day ago

@biggive/components v202405101333.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 day 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>
202404301101.0.0

11 days ago

202404251048.0.0

16 days ago

202404251627.0.0

16 days ago

202404251530.0.0

16 days ago

202404241313.0.0

17 days ago

202404240935.0.0

17 days ago

202404241507.0.0

17 days ago

202404151401.0.0

26 days ago

202404151335.0.0

26 days ago

202404151355.0.0

26 days ago

202404111349.0.0

1 month ago

202404020955.0.0

1 month ago

202403261241.0.0

2 months ago

202403221520.0.0

2 months ago

202403221512.0.0

2 months ago

202403221557.0.0

2 months ago

202403211223.0.0

2 months ago

202403191151.0.0

2 months ago

202403181322.0.0

2 months ago

202403151544.0.0

2 months ago

202403131230.0.0

2 months ago

202403111155.0.0

2 months ago

202403131235.0.0

2 months ago

202403041212.0.0

2 months ago

202403051213.0.0

2 months ago

202402291454.0.0

2 months ago

202402271602.0.0

2 months ago

202402271631.0.0

2 months ago

202402271300.0.0

2 months ago

202402261629.0.0

3 months ago

202402211431.0.0

3 months ago

202402221620.0.0

3 months ago

202402221726.0.0

3 months ago

202402221308.0.0

3 months ago

202402141056.0.0

3 months ago

202402141621.0.0

3 months ago

202402141508.0.0

3 months ago

202402141452.0.0

3 months ago

202402141810.0.0

3 months ago

202402141759.0.0

3 months ago

202402141520.0.0

3 months ago

202402141752.0.0

3 months ago

202402131729.0.0

3 months ago

202402131105.0.0

3 months ago

202402121535.0.0

3 months ago

202402121529.0.0

3 months ago

202402121546.0.0

3 months ago

202402121643.0.0

3 months ago

202402081405.0.0

3 months ago

202402081706.0.0

3 months ago

202402081415.0.0

3 months ago

202402071443.0.0

3 months ago

202402071203.0.0

3 months ago

202402071221.0.0

3 months ago

202402071230.0.0

3 months ago

202402071235.0.0

3 months ago

202402061444.0.0

3 months ago

202402061439.0.0

3 months ago

202402051215.0.0

3 months ago

202402051143.0.0

3 months ago

202402021504.0.0

3 months ago

202402021513.0.0

3 months ago

202402011429.0.0

3 months ago

202402011419.0.0

3 months ago

202402021019.0.0

3 months ago

202402011424.0.0

3 months ago

202402021430.0.0

3 months ago

202401311522.0.0

3 months ago

202401311504.0.0

3 months ago

202401311509.0.0

3 months ago

202401301118.0.0

3 months ago

202401291107.0.0

3 months ago

202401291113.0.0

3 months ago

202401301136.0.0

3 months ago

202401301139.0.0

3 months ago

202401291059.0.0

3 months ago

202401301126.0.0

3 months ago

202401231203.0.0

4 months ago

202401191800.0.0

4 months ago

202401191520.0.0

4 months ago

202401191515.0.0

4 months ago

202401191252.0.0

4 months ago

202401191805.0.0

4 months ago

202401181400.0.0

4 months ago

202401181419.0.0

4 months ago

202401181425.0.0

4 months ago

202401171215.0.0

4 months ago

202401171202.0.0

4 months ago

202401171206.0.0

4 months ago

202401151140.0.0

4 months ago

202401151138.0.0

4 months ago

202401151136.0.0

4 months ago

202401161507.0.0

4 months ago

202401151137.0.0

4 months ago

202401121321.0.0

4 months ago

202401091632.0.0

4 months ago

202401091650.0.0

4 months ago

202401051206.0.0

4 months ago

202401051222.0.0

4 months ago

202401051020.0.0

4 months ago

202401021511.0.0

4 months ago

202401021355.0.0

4 months ago

202401021134.0.0

4 months ago

202401021340.0.0

4 months ago

202401021239.0.0

4 months ago

202401031141.0.0

4 months ago

202401021209.0.0

4 months ago

202401021422.0.0

4 months ago

202401021213.0.0

4 months ago

202401021140.0.0

4 months ago

202312291805.0.0

4 months ago

202312291757.0.0

4 months ago

202312291818.0.0

4 months ago

202312291829.0.0

4 months ago

202312071742.0.0

5 months ago

202312041141.0.0

5 months ago

202312031231.0.0

5 months ago

202311241148.0.0

6 months ago

202311240945.0.0

6 months ago

202308250924.0.0

9 months ago

202308161206.0.0

9 months ago

202308161033.0.0

9 months ago

202309180924.0.0

8 months ago

202311211130.0.0

6 months ago

202307100703.0.0

10 months ago

202307100729.0.0

10 months ago

202310301020.0.0

6 months ago

202308101557.0.0

9 months ago

202310310929.0.0

6 months ago

202309211700.0.0

8 months ago

202307091949.0.0

10 months ago

202308101621.0.0

9 months ago

202309061001.0.0

8 months ago

202311211421.0.0

6 months ago

202308161134.0.0

9 months ago

202311061800.0.0

6 months ago

202308161105.0.0

9 months ago

202308111427.0.0

9 months ago

202309210829.0.0

8 months ago

202307271726.0.0

10 months ago

202309141628.0.0

8 months ago

202309200915.0.0

8 months ago

202307190919.0.0

10 months ago

202308161015.0.0

9 months ago

202308161158.0.0

9 months ago

202307091858.0.0

10 months ago

202307100721.0.0

10 months ago

202308161124.0.0

9 months ago

202311211120.0.0

6 months ago

202307100656.0.0

10 months ago

202310310925.0.0

6 months ago

202308171555.0.0

9 months ago

202309141604.0.0

8 months ago

202307171427.0.0

10 months ago

202308311526.0.0

8 months ago

202308221410.0.0

9 months ago

202307051615.0.0

10 months ago

202309281045.0.0

8 months ago

202311211301.0.0

6 months ago

202308151517.0.0

9 months ago

202307200905.0.0

10 months ago

202308181645.0.0

9 months ago

202309180958.0.0

8 months ago

202308161118.0.0

9 months ago

202311201334.0.0

6 months ago

202308161146.0.0

9 months ago

202309260920.0.0

8 months ago

202308241036.0.0

9 months ago

202309201242.0.0

8 months ago

202309191556.0.0

8 months ago

202308141050.0.0

9 months ago

202308021605.0.0

9 months ago

202308101705.0.0

9 months ago

202307191013.0.0

10 months ago

202309151020.0.0

8 months ago

202308171208.0.0

9 months ago

202308180939.0.0

9 months ago

202311091230.0.0

6 months ago

202307102042.0.0

10 months ago

202311211133.0.0

6 months ago

202308111157.0.0

9 months ago

202308180855.0.0

9 months ago

202309011438.0.0

8 months ago

202307271559.0.0

10 months ago

202307191002.0.0

10 months ago

202308161137.0.0

9 months ago

202307201413.0.0

10 months ago

202307100646.0.0

10 months ago

202309271411.0.0

8 months ago

202309141649.0.0

8 months ago

202309040952.0.0

8 months ago

202306210851.0.0

11 months ago

202305241149.0.0

12 months ago

202305301947.0.0

12 months ago

202305230804.0.0

12 months ago

202305171609.0.0

12 months ago

202305161606.0.0

12 months ago

1.0.187

1 year ago

1.0.186

1 year ago

1.0.189

1 year ago

1.0.188

1 year ago

1.0.185

1 year ago

1.0.198

1 year ago

1.0.197

1 year ago

1.0.199

1 year ago

1.0.194

1 year ago

1.0.193

1 year ago

1.0.196

1 year ago

1.0.195

1 year ago

1.0.190

1 year ago

1.0.192

1 year ago

1.0.191

1 year ago

1.0.143

1 year ago

1.0.142

1 year ago

1.0.145

1 year ago

1.0.144

1 year ago

1.0.141

1 year ago

1.0.140

1 year ago

1.0.147

1 year ago

1.0.146

1 year ago

1.0.149

1 year ago

1.0.148

1 year ago

1.0.132

1 year ago

1.0.131

1 year ago

1.0.134

1 year ago

1.0.133

1 year ago

1.0.130

1 year ago

1.0.139

1 year ago

1.0.136

1 year ago

1.0.135

1 year ago

1.0.138

1 year ago

1.0.137

1 year ago

1.0.165

1 year ago

1.0.167

1 year ago

1.0.166

1 year ago

1.0.161

1 year ago

1.0.160

1 year ago

1.0.163

1 year ago

1.0.162

1 year ago

1.0.169

1 year ago

1.0.168

1 year ago

1.0.154

1 year ago

1.0.153

1 year ago

1.0.156

1 year ago

1.0.150

1 year ago

1.0.152

1 year ago

1.0.151

1 year ago

1.0.158

1 year ago

1.0.157

1 year ago

1.0.159

1 year ago

1.0.1

2 years ago

1.0.101

2 years ago

1.0.100

2 years ago

1.0.183

1 year ago

1.0.182

1 year ago

1.0.184

1 year ago

1.0.107

2 years ago

1.0.106

2 years ago

1.0.9

2 years ago

1.0.109

2 years ago

1.0.8

2 years ago

1.0.108

2 years ago

1.0.7

2 years ago

1.0.103

2 years ago

1.0.6

2 years ago

1.0.102

2 years ago

1.0.5

2 years ago

1.0.105

2 years ago

1.0.4

2 years ago

1.0.104

2 years ago

1.0.3

2 years ago

1.0.181

1 year ago

1.0.180

1 year ago

1.0.176

1 year ago

1.0.175

1 year ago

1.0.178

1 year ago

1.0.177

1 year ago

1.0.172

1 year ago

1.0.171

1 year ago

1.0.174

1 year ago

1.0.173

1 year ago

1.0.179

1 year ago

1.0.170

1 year ago

1.0.121

2 years ago

1.0.120

2 years ago

1.0.123

2 years ago

1.0.122

2 years ago

0.0.23

2 years ago

0.0.25

2 years ago

1.0.129

1 year ago

1.0.128

1 year ago

1.0.125

2 years ago

1.0.124

2 years ago

1.0.127

1 year ago

1.0.126

2 years ago

1.0.82

2 years ago

1.0.81

2 years ago

1.0.110

2 years ago

1.0.112

2 years ago

1.0.111

2 years ago

1.0.118

2 years ago

1.0.117

2 years ago

1.0.119

2 years ago

1.0.114

2 years ago

1.0.113

2 years ago

1.0.116

2 years ago

1.0.115

2 years ago

1.0.91

2 years ago

1.0.95

2 years ago

1.0.93

2 years ago

1.0.92

2 years ago

1.0.99

2 years ago

1.0.98

2 years ago

1.0.97

2 years ago

1.0.96

2 years ago

0.0.21

2 years ago

0.0.20

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago