Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@uob-web-and-digital/uob-components
Advanced tools
University of Birmingham - Component Library
This is the frontend component library for the University of Birmingham website utilising Styled Components
Before setting up the UoB component library it is required that you setup Prettier to format JS.
Node: ^16.6.2
NPM: ^7.20.3
*Supported version last updated: 09/12/2021
Launch VS Code Quick Open (Cmd+P for Mac, Ctrl+P for Windows) and paste the following command, and press enter.
ext install esbenp.prettier-vscode
Once the extension is installed you can then configure VSCode to automtically format JS upon saving by adding the following to your VSCode settings.json
file:
"editor.defaultFormatter": null, // (Optional) it is possible to set this as "esbenp.prettier-vscode" for everything but not recommended
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}
git clone git@github.com:Mixd/uob-components-new.git
npm install
from the project rootRun npm run storybook
from the project root. This will run a new instance of Storybook JS that can be accessed from localhost:6006
.
Changes made locally are automatically compiled and the browser instance of Storybook will automaticaly refresh, hot-loading changes very quickly where possible.
The visible Storybook for sharing changes is accessed at https://bham-storybook.mixd.co.uk/.
This is automatically deployed and built when changes are pushed to the development branch of the GitHub repository.
As this is likely to be ahead of the published package, any new changes that are anticipated to be published separately should be developed in separate feature branches to allow for merging into development and master separately.
The repository will need publishing to the NPMJS package library https://www.npmjs.com/package/@uob-web-and-digital/uob-components before it can be used in the UoB website.
When the library in ready for a new release of the NPM package, you will need to increase the version number in the package.json and run a npm install
to ensure the project gets updated with this version. You will need to be logged into NPM in order to publish a new package. This can be done easily by running npm login
in your terminal, then follow the instructions to login. Once logged in, you will be able to run the following command to release your new version, ready for Birmingham to use: npm publish
As this is a manual process, ensure that the master
branch of the repository is always in sync with the currently published package.
Components should always be created within the src/components
folder.
Each component should have a name that describes what it is as generically as possible and shouldn't factor in its expected location. A good example of this would be a component called 'accordion', the name is short and describes its function. A not so great name would be news-accordion because it loses semantics when used outside of the news section.
Once a component has a good name you can create a new folder within src/components
that is based on the name. The format of this folder name should always be lowercase, with multiple words being seperated by dashes i.e. content-sidebar-group
.
Within the component folder you must create the following 3 files:
component-folder
|_ {ComponentName}.js
|_ {ComponentName}.stories.js
|_ Styles.js
Files within the folder should be named in PascalCase which means that each word in the name should have a capital first letter i.e. MyCoolComponent.
This file is where the Component Structure is defined.
This file allows developers to pass in mockup content to the component that will render within Storybook. More information is available in the Storybook docs Storybook JS - Defining Stories
this is where component styling is defined using Styled Components. Note: Styled components not only define the CSS styling but actually create the markup for elements within the component.
npm run build
to ensure that Webpack has compiled the components with no issues?npm install
to ensure that the project has been updated with the new version number?npm publish
to release the new package?The component library utilises styled-components, which is a library built for React that allows you to use a mixture of JavaScript and CSS (a technique called CSS-in-JS). Styling is considered to be tied to a specific component. An important feature of this library is that it generates unique class names for the styling. Therefore, generally for this project, class names should not be applied to any elements.
You should define an element within the {ComponentName}.js file, and import this in from the Styles.js file to create the markup. For example:
import React from "react";
import PropTypes from "prop-types";
import { Wrapper, Title } from "./Styles"; // These must be defined as named imports, therefore require curly braces wrapped around them
const Example = ({ title }) => {
return (
<Wrapper>
<Title>
{title}
</Title>
</Wrapper>
);
};
Example.propTypes = {
title: PropTypes.string.isRequired
};
export default Example;
import styled from "styled-components";
// Create a Title component that'll render a <h1> tag with some styles
const Title = styled.h1`
font-size: 1.5em;
text-align: center;
color: palevioletred;
`;
// Create a Wrapper component that'll render a <section> tag with some styles
const Wrapper = styled.section`
padding: 4em;
background: papayawhip;
`;
NOTE: styled-components has a lot of advanced capabilities, including being able to style an element dependent on a prop the component has received. It will be important to read up on their documentation to familiarise yourself with these features.
Global and theme variables have been defined for use across the project. This is mainly for the project’s design tokens: colours, font families, font weights, font sizes and spacing values. These can be referenced in the components as CSS variables, e.g. color: var(--color-black);. You will be able to find references of all token names in the Design Tokens section on the front-end of the Component Library, or within the /src/theme/GlobalStyles.js file in the code. The theme variables are also defined in an object in the /src/theme/ThemeVariables.js file for when JavaScript is needed to be used in particular instances. However, CSS variables should always take preference where possible.
FAQs
University of Birmingham - Component Library
We found that @uob-web-and-digital/uob-components demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.