Skip to content

Commit 1acab4b

Browse files
author
Hugo Bernier
committed
Initial version
1 parent 0ef08b6 commit 1acab4b

23 files changed

Lines changed: 17668 additions & 2 deletions

.editorconfig

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
8+
[*]
9+
10+
# change these settings to your own preference
11+
indent_style = space
12+
indent_size = 2
13+
14+
# we recommend you to keep these unchanged
15+
end_of_line = lf
16+
charset = utf-8
17+
trim_trailing_whitespace = true
18+
insert_final_newline = true
19+
20+
[*.md]
21+
trim_trailing_whitespace = false
22+
23+
[{package,bower}.json]
24+
indent_style = space
25+
indent_size = 2

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Dependency directories
7+
node_modules
8+
9+
# Build generated files
10+
dist
11+
lib
12+
solution
13+
temp
14+
*.sppkg
15+
16+
# Coverage directory used by tools like istanbul
17+
coverage
18+
19+
# OSX
20+
.DS_Store
21+
22+
# Visual Studio files
23+
.ntvs_analysis.dat
24+
.vs
25+
bin
26+
obj
27+
28+
# Resx Generated Code
29+
*.resx.ts
30+
31+
# Styles Generated Code
32+
*.scss.ts

.vscode/extensions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"msjsdiag.debugger-for-chrome"
4+
]
5+
}

.vscode/launch.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
/**
3+
* Install Chrome Debugger Extension for Visual Studio Code to debug your components with the
4+
* Chrome browser: https://aka.ms/spfx-debugger-extensions
5+
*/
6+
"version": "0.2.0",
7+
"configurations": [{
8+
"name": "Local workbench",
9+
"type": "chrome",
10+
"request": "launch",
11+
"url": "https://localhost:4321/temp/workbench.html",
12+
"webRoot": "${workspaceRoot}",
13+
"sourceMaps": true,
14+
"sourceMapPathOverrides": {
15+
"webpack:///../../../src/*": "${webRoot}/src/*",
16+
"webpack:///../../../../src/*": "${webRoot}/src/*",
17+
"webpack:///../../../../../src/*": "${webRoot}/src/*"
18+
},
19+
"runtimeArgs": [
20+
"--remote-debugging-port=9222"
21+
]
22+
},
23+
{
24+
"name": "Hosted workbench",
25+
"type": "chrome",
26+
"request": "launch",
27+
"url": "https://enter-your-SharePoint-site/_layouts/workbench.aspx",
28+
"webRoot": "${workspaceRoot}",
29+
"sourceMaps": true,
30+
"sourceMapPathOverrides": {
31+
"webpack:///../../../src/*": "${webRoot}/src/*",
32+
"webpack:///../../../../src/*": "${webRoot}/src/*",
33+
"webpack:///../../../../../src/*": "${webRoot}/src/*"
34+
},
35+
"runtimeArgs": [
36+
"--remote-debugging-port=9222",
37+
"-incognito"
38+
]
39+
}
40+
]
41+
}

.vscode/settings.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Place your settings in this file to overwrite default and user settings.
2+
{
3+
// Configure glob patterns for excluding files and folders in the file explorer.
4+
"files.exclude": {
5+
"**/.git": true,
6+
"**/.DS_Store": true,
7+
"**/bower_components": true,
8+
"**/coverage": true,
9+
"**/lib-amd": true,
10+
"src/**/*.scss.ts": true
11+
},
12+
"typescript.tsdk": ".\\node_modules\\typescript\\lib"
13+
}

.yo-rc.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"@microsoft/generator-sharepoint": {
3+
"version": "1.4.1",
4+
"libraryName": "react-application-injectcss",
5+
"libraryId": "b2322574-549b-4510-99d8-1351d9457a97",
6+
"environment": "spo"
7+
}
8+
}

README.md

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,71 @@
1-
# react-application-injectcss
2-
An SPFx extension that injects CSS on every page
1+
# Spfx Applications Customiser CSS Injection
2+
3+
## Summary
4+
This sample shows how to inject a custom Cascading Style Sheet (CSS) on modern pages.
5+
6+
![Sample super ugly CSS](./assets/sampleresults.png)
7+
8+
__Note__: This code is provided as a sample only. Keep in mind that Microsoft may change page elements and styles at any time, rendering your custom CSS useless. It is preferrable to use well-known HTML element placeholders.
9+
10+
When you need to make minor cosmetic changes to modern pages (e.g.: match your corporate branding guidelines) and cannot use placeholders,you can create a custom CSS and inject on every modern page.
11+
12+
13+
## Used SharePoint Framework Version
14+
15+
![SPFx v1.4.1](https://img.shields.io/badge/SPFx-1.4.1-green.svg)
16+
17+
## Applies to
18+
19+
* [SharePoint Framework Extensions](https://dev.office.com/sharepoint/docs/spfx/extensions/overview-extensions)
20+
* [Office 365 developer tenant](http://dev.office.com/sharepoint/docs/spfx/set-up-your-developer-tenant)
21+
22+
## Solution
23+
24+
Solution|Author(s)
25+
--------|---------
26+
react-application-injectcss|Hugo Bernier ([Tahoe Ninjas](http://tahoeninjas.blog), @bernierh)
27+
28+
## Version history
29+
30+
Version|Date|Comments
31+
-------|----|--------
32+
1.0.0|07 May, 2018|Initial release
33+
34+
## Disclaimer
35+
36+
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
37+
38+
---
39+
40+
## Minimal Path to Awesome
41+
42+
* clone repo
43+
* create a custom CSS file that meets your needs. For example, this CSS will make the site logos round and will add an ugly red colour at the top of every page.
44+
45+
```
46+
.ms-compositeHeader {
47+
background-color: red;
48+
}
49+
50+
.ms-siteLogoContainerOuter {
51+
border-radius: 50%;
52+
border-width: 3px;
53+
}
54+
55+
.ms-siteLogo-actual {
56+
border-radius: 50%;
57+
}
58+
```
59+
* upload the CSS file to a shared location on your SharePoint tenant. For example, in the `Styles Library` of the root site collection.
60+
* get the URL to your custom CSS. For example: `/Style%20Library/custom.css`
61+
62+
* update _serve.json_ pointing to your site collection home page change the `cssurl` property with the URL to your custom CSS.
63+
* run _gulp serve_
64+
65+
## Features
66+
67+
Sample SharePoint Framework application customiser injecting a custom CSS in the HTML header.
68+
69+
This sample illustrates the following concepts on top of the SharePoint Framework:
70+
71+
* HTML manipulation

assets/sampleresults.png

1.32 MB
Loading

config/config.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "https://dev.office.com/json-schemas/spfx-build/config.2.0.schema.json",
3+
"version": "2.0",
4+
"bundles": {
5+
"inject-css-application-customizer": {
6+
"components": [
7+
{
8+
"entrypoint": "./lib/extensions/injectCss/InjectCssApplicationCustomizer.js",
9+
"manifest": "./src/extensions/injectCss/InjectCssApplicationCustomizer.manifest.json"
10+
}
11+
]
12+
}
13+
},
14+
"externals": {},
15+
"localizedResources": {
16+
"InjectCssApplicationCustomizerStrings": "lib/extensions/injectCss/loc/{locale}.js"
17+
}
18+
}

config/copy-assets.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "https://dev.office.com/json-schemas/spfx-build/copy-assets.schema.json",
3+
"deployCdnPath": "temp/deploy"
4+
}

0 commit comments

Comments
 (0)