Skip to content

Commit

Permalink
PR #10: Add ms-accent variable
Browse files Browse the repository at this point in the history
Update typography styles
  • Loading branch information
StfBauer committed Dec 20, 2018
1 parent dd61014 commit e9d9653
Show file tree
Hide file tree
Showing 6 changed files with 1,847 additions and 983 deletions.
30 changes: 14 additions & 16 deletions _office.theme.typography.scss
@@ -1,4 +1,4 @@
@mixin uiUseRem($rem){
@mixin uiUseRem($rem) {
$useRem: $rem !global;
}

Expand Down Expand Up @@ -36,27 +36,25 @@
$fdTitle: nth($fontDef, 1); // get font weight
$fdWeight: nth($fontDef, 2); //
$fdValue: $fdWeight; // @warn $fdTitle $fabric-font $fdTitle == nth($fabric-font, 1);

@if $fdTitle==nth($fabric-font, 1) {
font-weight: call($fdValue);
}

}
}

// Converts the font size out In EM
@mixin uiFontSize($fabric-font) {

@each $fontDef in $fontSizes {

// check Office UI Frabric name
$fdTitle: nth($fontDef, 1); // base office ui fabric in PX value
$fdSizePx: nth($fontDef, 2); // base office ui fabric in EM value
$fdSizeEm: if($useRem, pxToRem($fdSizePx), pxToEm($fdSizePx)); // get font weight
$fdWeight: nth($fontDef, 3);

@if $fdTitle==$fabric-font {
font-size: $fdSizeEm;
}

@each $fontDef in $fontSizes {

// check Office UI Frabric name
$fdTitle: nth($fontDef, 1); // base office ui fabric in PX value
$fdSizePx: nth($fontDef, 2); // base office ui fabric in EM value
$fdSizeEm: if($useRem, pxToRem($fdSizePx), pxToEm($fdSizePx)); // get font weight
$fdWeight: nth($fontDef, 3);

@if $fdTitle==$fabric-font {
font-size: $fdSizeEm;
}
}
}
}
5 changes: 4 additions & 1 deletion _office.theme.vars.scss
Expand Up @@ -86,4 +86,7 @@ $ms-severeWarningText: "[theme:severeWarningText, default: #333333]";
/** Success **/
$ms-success: "[theme:success, default: #107c10]";
$ms-successBackground: "[theme:successBackground, default: #dff6dd]";
$ms-successText: "[theme:successText, default: #333333]";
$ms-successText: "[theme:successText, default: #333333]";

/* Misc Colors */
$ms-accent: "[theme:accent, default: #8764b8]";
16 changes: 8 additions & 8 deletions index.js
Expand Up @@ -199,7 +199,7 @@ const nsPrefix = "ouif-"
export default function uiFabricCSS() {

// createCSSVariables() {
let themeCache = null,
var themeCache = null,
allVariables = [];

if (document.getElementById(cssVarThemeID)) {
Expand All @@ -212,9 +212,9 @@ export default function uiFabricCSS() {

if ('theme' in themeCache && themeCache.theme !== undefined) {

let keys = Object.keys(themeCache.theme);
var keys = Object.keys(themeCache.theme);

keys.forEach(element => {
keys.forEach(function(element){
allVariables.push(' --' + nsPrefix + element + ': ' + themeCache.theme[element] + ';');
});

Expand All @@ -230,13 +230,13 @@ export default function uiFabricCSS() {

}

var includeInRoot = `:root{
${allVariables.sort().join('\r\n')}
}`;
var includeInRoot = ':root{'+
allVariables.sort().join('\r\n')
'}';

let styleSheetFragment = document.createElement('style');
var styleSheetFragment = document.createElement('style');
styleSheetFragment.id = cssVarThemeID;
styleSheetFragment.innerHTML = includeInRoot;
document.head.appendChild(styleSheetFragment);

};
};
4 changes: 2 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "spfx-uifabric-themes",
"version": "0.4.0",
"version": "0.5.0-0",
"description": "Include theme slots in your SharePoint Framework Project",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -29,7 +29,7 @@
"sass-test.sh": "^1.4.0"
},
"devDependencies": {
"gulp": "^3.9.1",
"gulp": "^4.0.0",
"gulp-mocha": "^6.0.0",
"mocha": "^5.2.0",
"sass-true": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion tests/fonttest.scss
Expand Up @@ -219,7 +219,6 @@ $fontsExpectedRem: (
@include uiFontSize(su);
@include uiUseRem(false);
@include uiFontSize(su);

}
@include expect {
font-size: #{nth($fontSizeExpectedRem, 1)};
Expand All @@ -230,3 +229,4 @@ $fontsExpectedRem: (

}


0 comments on commit e9d9653

Please sign in to comment.