Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
170cab6
fixing typo change
SriHV Mar 1, 2024
ba0d688
Added Visual tests, example components, generate_backstop
SriHV Apr 30, 2024
ddd7599
Resolving Readme confilcts
SriHV Apr 30, 2024
86a2772
changes in readme
SriHV May 2, 2024
ebb0497
Changes in readme
SriHV May 3, 2024
3d92ace
Merge branch 'main' into testing-to-include-backstopjs
SriHV May 13, 2024
1a618dc
Update .gitignore
SriHV May 13, 2024
eb75985
Update application.py
SriHV May 13, 2024
ed49efc
Update README.md
SriHV May 13, 2024
4927bce
Update README.md
SriHV May 13, 2024
e1b7f02
Update README.md
SriHV May 13, 2024
39168c4
changes as per recent comments
SriHV May 23, 2024
27e28de
Update Makefile
SriHV May 23, 2024
26f5ef7
Update application.py
SriHV May 23, 2024
3201b43
changes in readme
SriHV May 23, 2024
0bd9ae1
added pull_request_template
SriHV May 24, 2024
f38b29e
fixing make file
SriHV May 24, 2024
8b98830
Changes made to support design system in Jinja
SriHV May 28, 2024
adf7d67
testing ..
SriHV Jul 29, 2024
50d8ded
Testing ..
SriHV Jul 29, 2024
b858ecf
Merge to main and changes in pre-commit
SriHV Aug 9, 2024
3bcfbcf
removing comments
SriHV Aug 9, 2024
67311c6
Ordering hooks
SriHV Aug 9, 2024
348d98e
Ordering hooks
SriHV Aug 9, 2024
7cd48e0
Ordering hooks
SriHV Aug 9, 2024
2c05edc
changes as per comments
SriHV Aug 9, 2024
685146f
changing latest design system version
SriHV Aug 30, 2024
a26259d
Updating images
SriHV Aug 30, 2024
4533657
merge with load-ds-template-in-jinja
SriHV Sep 3, 2024
fb4abb7
Adding images
SriHV Sep 3, 2024
1679a9a
changes in package.json
SriHV Sep 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .design-system-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
67.0.5
70.0.12
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
env
templates/components
templates/layout
node_modules
node_modules
backstop_data/bitmaps_test/
backstop_data/html_report/
backstop.json
10 changes: 6 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
repos:
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
args: ['--profile=black']
- repo: https://github.com/ambv/black
rev: 24.4.2
hooks:
Expand All @@ -15,7 +20,4 @@ repos:
rev: 7.1.0
hooks:
- id: flake8
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
args: ['--max-line-length=88']
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,15 @@ format-python:

format:
npx prettier --write .

generate-backstopjs:
python3 -m generate_backstop_config

reference:
backstop reference

test:
backstop test

approve:
backstop approve
16 changes: 16 additions & 0 deletions README.md

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Line 8 has a typo it should be "preprocessor" not "preprosser", "version" needs to be "versions" and "script" should be added to the end of the sentence.

@rmccar rmccar May 24, 2024

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Still need to add "script" here to the end of the sentence

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Line 3 has a typo it should be "implemented" not "implemenented"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Line 7 has a typo it should be "switching" not "switch"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Line 33 should be
"For running this application, load and update the design system templates first using the below command (the design system version is specified in the .design-system-version file)."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've removed this line now.

Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,19 @@ npm install
## Running the Application

For running this application, run `make run` which first executes `scripts/load_release.sh` script that downloads the Design System macros zip file from the github release and unzips them into a templates folder. Then, `flask --app application run ` renders all the example components as displayed in the Design System at `http://127.0.0.1:5000`. The CSS and JS are pulled in at runtime from the CDN.

## Visual Tests

For the visual regression tests BackstopJS is used. To install BackstopJS run:

```
npm install -g backstopjs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To be consistent with the DS we should probably use yarn not npm

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As discussed in prev tech session, when I try to install yarn its downloading too many packages that I think are not required. Can you check this and tell me if its doing the same for you also

```

Note-: Make sure to install npm package([link](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)) before before installing BackstopJS.

To utilize BackstopJS, the workflow is as follows:

`make generate-backstopjs`: This python file generates `backstop.json` file which has the config for BackstopJS

`make test`: This runs the tests which creates a set of screenshots, compares them with reference screenshots and shows any changes in the visual report (`backstop_data/html_report`). Note-: Make sure to keep the local server running before executing this step.
63 changes: 60 additions & 3 deletions application.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,70 @@
from flask import Flask, render_template
import os

import frontmatter
from flask import Flask, render_template, render_template_string, send_from_directory
from jinja2 import ChainableUndefined

app = Flask(__name__)


def setAttributes(dictionary, attributes):
for key in attributes:
dictionary[key] = attributes[key]
return dictionary


app.jinja_env.filters["setAttributes"] = setAttributes
app.jinja_env.undefined = ChainableUndefined


@app.route("/<path:filename>")
def generate_images(filename):
return send_from_directory("static/", filename)


@app.route("/")
def hello_world():
return render_template("index.html", param="Hello world")
def index():
root_directory = "templates/components"
directories = {
directory
for directory in os.listdir(root_directory)
for file in os.listdir(os.path.join(root_directory, directory))
if file.startswith("example")
}
return render_template("index.html", example_files=sorted(directories))


@app.route("/components/<component_name>")
def component(component_name):
example_files = [
file
for file in os.listdir(f"templates/components/{component_name}/")
if file.startswith("example")
]
return render_template(
"component-examples-list.html",
example_files=sorted(example_files),
component_name=component_name,
)


@app.route("/components/<component_name>/<filename>")
def example(component_name, filename):
try:
with open(f"templates/components/{component_name}/{filename}", "r") as content:
content = frontmatter.load(content)
if "layout" in content.metadata:
template = content.content
else:
template = (
"{% extends 'layout/_template.njk' %}"
+ "{% block body %}<div class='ons-u-p-m'>"
+ content.content
+ "</div>{% endblock %}"
)
return render_template_string(template)
except FileNotFoundError:
return "File not found"


if __name__ == "__main__":
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading