Skip to content

Commit e8ea938

Browse files
authored
Merge pull request creativecommons#648 from MuluhGodson/cc_global_article
[Blog Entry] Building the CC Global Components
2 parents 000451a + 840d935 commit e8ea938

File tree

6 files changed

+135
-0
lines changed

6 files changed

+135
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
username: MuluhGodson
2+
---
3+
name: Muluh MG Godson
4+
---
5+
md5_hashed_email: 2250c5b355c93e0025eede14ead60028
6+
---
7+
about:
8+
MG was an [Outreachy](https://outreachy.org) intern for Creative Commons. He is
9+
`@muluhgodson` on the CC Slack.
Loading
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
title: Building the CC Global Components Library
2+
---
3+
categories:
4+
5+
outreachy
6+
community
7+
design
8+
---
9+
author: MuluhGodson
10+
---
11+
pub_date: 2022-03-17
12+
---
13+
body:
14+
15+
### Introduction
16+
During the course of my Outreachy internship with the Creative Commons, I got to work on some cool projects, one of which is the CC Global Components
17+
library supervised by my mentor [Brylie Christopher Oxley](https://github.com/brylie).
18+
19+
Having a unified design theme/look or experience accross the different CC websites has always been an important factor while developing these
20+
websites.
21+
With this in mind, there are several components which are part of most CC web properties. The three components in particular are:-
22+
23+
- ** The Global navigation menu ** : displayed on sub-paths of the main creativecommons.org website, such as /licenses
24+
- ** The Global footer ** : displayed on most Creative Commons properties
25+
- ** The Explore CC component ** : displayed on all CC web properties, such as Global Summit etc.
26+
27+
Instead of having each project implement these components leading to code duplication accross projects and maintenance issues, we decided it was
28+
preferable
29+
to have a seperate library of these components which finally led to the CC Global Components project.
30+
31+
32+
### Choosing a technology
33+
34+
The goal of the Global components library was to build a custom web component that can be served via CDN. While planning, we needed to decide on
35+
the technology to use. Agreeably, most web frameworks like React and Vue can be used to develop this but we wanted
36+
a simple implementation with fewer dependencies. Some ideal characteristics of what we were looking for was a technology that meets the following
37+
criteria:
38+
39+
- Web Standards oriented
40+
- Clean separation of HTML, CSS, and JavaScript (structure, aesthetics, and functionality)
41+
- Lightweight / small bundle size
42+
- Loosely coupled (no tight or unrelated dependencies)
43+
44+
The two primary technologies we were considering were [Vue JS](https://v3.vuejs.org) and [Lightning Web Components](https://lwc.dev) but finally
45+
decided to use Vue JS
46+
since we already had other projects developed in Vue (such as the Chooser project).
47+
48+
49+
### Building the components
50+
51+
To scaffold the project, we used [Vue SFC rollup](https://www.npmjs.com/package/vue-sfc-rollup), which is a CLI templating utility that scaffolds
52+
a minimal setup for compiling a library of multiple Vue SFCs (Single File Components) - into a form ready to share via npm. With this,
53+
we could just focus on building the templates. We used [Vocabulary CSS](https://cc-vocabulary.netlify.app/), our own CC design package to style
54+
the components.
55+
56+
#### 1) CC Global Footer
57+
The CC Global Footer component was the easiest given that it's mostly static HTML. This component takes two attributes:
58+
- `logo-url`: which should point to the logo of the website it is used on.
59+
- `donation-url`: which is used for the donation button.
60+
61+
After importing the CDN script for the CC Global components, we can then use the CC Global footer in any page as such:
62+
63+
```HTML
64+
<cc-global-footer
65+
donation-url="http://example.com"
66+
logo-url="/example/logo-white.png"
67+
/>
68+
```
69+
70+
and this renders as shown below:
71+
72+
![CC Global Footer](cc_global_footer.png)
73+
74+
75+
#### 2) CC Explore
76+
77+
The CC Explore component is an expandable banner which coontains links to all the CC Web properties. This component use a click listener which just
78+
toggles the expandable banner to show or hide when it is clicked. As with the CC Global Footer component, the CC Explore component takes two attributes.
79+
80+
```HTML
81+
<cc-explore
82+
donation-url="http://example.com"
83+
logo-url="/example/logo-white.png"
84+
/>
85+
```
86+
and this renders as shown below:
87+
88+
![CC Explore](cc_explore.gif)
89+
90+
91+
#### 3) CC Global Header
92+
93+
The CC Global Header was an important component given that we had to make API calls to be able to render the Menu items for downstream projects
94+
such as the [Licenses and Tools](https://github.com/creativecommons/cc-legal-tools-app). We used the Axios library for the API calls to the Wordpress
95+
backend of the parent project [Projec_creativecommons.org](https://github.com/creativecommons/project_creativecommons.org).
96+
97+
The CC Global Header has three required attributes, `base-url`, `donation-url` and `logo-url`, which are the URLs used for the API call,
98+
Donation button and Logo respectively. There is one additional attribute `use-menu-placeholders` you can set which renders placeholder Menu Items
99+
if you are in a development environment. However, for a stagin/production setup we do not use this attribute.
100+
101+
```HTML
102+
<cc-global-header
103+
base-url="http://127.0.0.1:8000"
104+
donation-url="http:/example.com"
105+
use-menu-placeholders
106+
logo-url="/example/logo-black.png"
107+
/>
108+
```
109+
110+
and this renders as shown:
111+
112+
![CC Global Header](cc_global_header.png)
113+
114+
### Conclusion
115+
116+
The first version of this library (0.1.1) was released and published to NPM on Dec 10, 2021. Till date [the time of this writing] we have had several
117+
changes and optimizations to the code and are currently on version `0.5.0`. This was a really enriching experience for me as it was my first time
118+
working with Vue JS. We've also had additional code review and optimizations from [Timid Robot](/blog/authors/TimidRobot/).
119+
120+
The CC Global Components with all 3 components used renders as:
121+
122+
![CC global components](cc_global_components.gif)
123+
124+
You can find the CC Global Components project at:
125+
- GitHub: [CC Global Components](https://github.com/creativecommons/cc-global-components)
126+
- NPM: [cc-global-components](https://www.npmjs.com/package/@creativecommons/cc-global-components)

0 commit comments

Comments
 (0)