Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added initial implementation of loader - spinner #1631

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/vf-componenet-rollup/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ button {
@import 'vf-pagination/vf-pagination.scss';
@import 'vf-pagination/vf-pagination--full.scss';
@import 'vf-back-to-top/vf-back-to-top.scss';
@import 'vf-indicator-loader/vf-indicator-loader.scss';

/* All Visual Framework Containers */

Expand Down
4 changes: 4 additions & 0 deletions components/vf-indicator-loader/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bin
.github
.travis.yml
node_modules
4 changes: 4 additions & 0 deletions components/vf-indicator-loader/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### 1.0.0-alpha.1

* Basic implementation of vf-indicator-loader component
* [Tracking issue](https://github.com/visual-framework/vf-core/issues/1332)
46 changes: 46 additions & 0 deletions components/vf-indicator-loader/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Loader component

[![npm version](https://badge.fury.io/js/%40visual-framework%2Fvf-indicator-loader.svg)](https://badge.fury.io/js/%40visual-framework%2Fvf-indicator-loader)

## About

An anchor or JavaScript button to scroll the user to top of the current page, or to a target element.
khawkins98 marked this conversation as resolved.
Show resolved Hide resolved

## Usage

Recommended reading: https://www.nngroup.com/articles/progress-indicators/

### Spinner variant:
This indicator should be reserved for actions that take between 2-10 seconds.

## Install

This repository is distributed with [npm][https://www.npmjs.com/]. After [installing npm][https://www.npmjs.com/get-npm] and [yarn](https://classic.yarnpkg.com/en/docs/install), you can install `vf-indicator-loader` with this command.

```
$ yarn add --dev @visual-framework/vf-indicator-loader
```

### JS

You should import this component in `./components/vf-component-rollup/scripts.js` or your other JS process:

```js
// no js yet for this component
```

### Sass/CSS

The style files included are written in [Sass](https://sass-lang.com/). If you're using a VF-core project, you can import it like this:

```
@import "@visual-framework/vf-indicator-loader/index.scss";
```

Make sure you import Sass requirements along with the modules. You can use a [project boilerplate](https://stable.visual-framework.dev/building/) or the [`vf-sass-starter`](https://stable.visual-framework.dev/components/vf-sass-starter/)

## Help

- [Read the Visual Framework troubleshooting](https://stable.visual-framework.dev/troubleshooting/)
- [Open a ticket](https://github.com/visual-framework/vf-core/issues)
- [Chat on Slack](https://join.slack.com/t/visual-framework/shared_invite/enQtNDAxNzY0NDg4NTY0LWFhMjEwNGY3ZTk3NWYxNWVjOWQ1ZWE4YjViZmY1YjBkMDQxMTNlNjQ0N2ZiMTQ1ZTZiMGM4NjU5Y2E0MjM3ZGQ)
16 changes: 16 additions & 0 deletions components/vf-indicator-loader/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// setup files required

// sass-lint:disable clean-import-paths
@import 'vf-global-variables';
@import 'vf-variables';
@import 'vf-functions';
@import 'vf-mixins';

// component specific styles

@import 'vf-indicator-loader.variables.scss';
@import 'vf-indicator-loader.scss';

// component variant styles
// @import 'vf-indicator-loader--variant.scss';

23 changes: 23 additions & 0 deletions components/vf-indicator-loader/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"version": "1.0.0-alpha.2",
"name": "@visual-framework/vf-indicator-loader",
"description": "vf-indicator-loader component",
"homepage": "",
"author": "VF",
"license": "Apache 2.0",
"style": "vf-indicator-loader.css",
"sass": "index.scss",
"main": "build/index.js",
"test": "echo \"Error: no test specified\" && exit 1",
"publishConfig": {
"access": "public"
},
"repo": "https://github.com/visual-framework/vf-core/tree/develop/components/vf-indicator-loader",
"bugs": {
"url": "https://github.com/visual-framework/vf-core/issues"
},
"keywords": [
"fractal",
"component"
]
}
25 changes: 25 additions & 0 deletions components/vf-indicator-loader/vf-indicator-loader.config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# The title shown on the component page
title: Loader
# Label shown on index pages
label: Loader
status: alpha
# The template used from /components/_previews
#
# Per-variant options
variants:
- name: default
hidden: true
- name: spinner
context:
container: false
# Global component context
context:
component-type: block
# custom-values: passed as {{custom-values}}
# - note: you in your custom-values you should use dashes `-`
# and not underscores `_` as underscores prevent inherited template use
# title: Title text
# text: String of text
# image: ../../assets/vf-component-name/assets/vf-component-name.png
# - note on paths: be sure to prefix with `../../`
# - Why? https://github.com/visual-framework/vf-core/issues/364
1 change: 1 addition & 0 deletions components/vf-indicator-loader/vf-indicator-loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// vf-indicator-loader
21 changes: 21 additions & 0 deletions components/vf-indicator-loader/vf-indicator-loader.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// vf-indicator-loader for React
// See vf-extensions-react for usage guidance

import React from "react";
import "./vf-indicator-loader.scss";

export function VFLoader({ container = false }) {
return container ? (
<div className="vf-box">
<div className="vf-indicator-loader--spinner__container">
<_VFLoader />
</div>
</div>
) : (
<_VFLoader />
);
}

function _VFLoader() {
return <div className="vf-indicator-loader--spinner__circle"></div>;
}
18 changes: 18 additions & 0 deletions components/vf-indicator-loader/vf-indicator-loader.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{# Make sure any variables are listed inside the following if statement #}
{% if context %}
{% set container = context.container %}
{% endif %}

{% if container == true %}
<!-- this HTML is for container if enabled -->
<div class="vf-box">
<div class="vf-indicator-loader--spinner__container">
{% endif %}

<div class="vf-indicator-loader--spinner__circle"></div>

{% if example == true %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

further above you used {% if container == true %}... did you mean to container here as well?

<!-- this HTML is for container if enabled -->
</div>
</div>
{% endif %}
51 changes: 51 additions & 0 deletions components/vf-indicator-loader/vf-indicator-loader.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// vf-indicator-loader

// **Thinking about deleting this file?**
// If your component needs no CSS/Sass, we still recommend leaving the
// scss files in place. As this is primarily a CSS framework, it is better to
// leave the empty files so you know a file wasn't accidently omitted.
// If you don't have any Sass, you can trim this block down to:
// "This page was intentionally left blank"

@import 'package.variables.scss';
// Debug information from component's `package.json`:
// ---
/*!
* Component: #{map-get($componentInfo, 'name')}
* Version: #{map-get($componentInfo, 'version')}
* Location: #{map-get($componentInfo, 'location')}
* Build time: #{map-get($componentInfo, 'buildTimeStamp')}
*/

@import 'vf-indicator-loader.variables.scss';

// You need to add this Sass file to ./components/vf-componenet-rollup/index.scss

.vf-indicator-loader--spinner__circle {
width: 32px;
height: 32px;
color: $vf-indicator-loader--border-color;
Copy link
Contributor

@khawkins98 khawkins98 Jul 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some suggestions on how to use the design tokens here. Might be clearest/best if I just do that and then we can look at the diff.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nitinja I still need to update this Sass, but if you could please look at the other PR comment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've addressed this with commit 0c370a6

position: relative;
display: inline-block;
border: 4px solid;
border-radius: 50%;
border-right-color: $vf-indicator-loader--border-color-highlight;
animation: rotate 1s linear infinite;
}

@keyframes rotate {
0% {
transform: rotate(0);
}
100% {
transform: rotate(360deg);
}
}

.vf-indicator-loader--spinner__container {
width: 100%;
height: 20rem;
display: flex;
justify-content: center;
align-items: center;
}
13 changes: 13 additions & 0 deletions components/vf-indicator-loader/vf-indicator-loader.variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

// vf-indicator-loader Sass variables file.
// ------------------------------------------------------------

// ------------------------------------------------------------
// Default component variables
// ------------------------------------------------------------

// $vf-indicator-loader--example-bg-color: set-color(vf-color--yellow);
// $vf-indicator-loader--example2-bg-color: set-ui-color(vf-ui-color--grey);

$vf-indicator-loader--border-color: var(--vf-color--neutral--300);
$vf-indicator-loader--border-color-highlight: var(--vf-color--neutral--600);