@financial-times/o-private-foundation 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +108 -0
  2. package/demos/src/demo.mustache +0 -0
  3. package/demos/src/demo.scss +1 -0
  4. package/main.js +60 -0
  5. package/main.scss +32 -0
  6. package/origami.json +26 -0
  7. package/package.json +33 -0
  8. package/src/scss/_brand.scss +68 -0
  9. package/src/scss/_tokens.scss +15 -0
  10. package/src/scss/_variables.scss +1 -0
  11. package/src/scss/o-buttons/custom-themes.scss +631 -0
  12. package/src/scss/o-buttons/main.scss +255 -0
  13. package/src/scss/o-colors/_functions.scss +354 -0
  14. package/src/scss/o-colors/_palette.scss +2 -0
  15. package/src/scss/o-colors/_variables.scss +50 -0
  16. package/src/scss/o-colors/main.scss +6 -0
  17. package/src/scss/o-grid/_functions.scss +90 -0
  18. package/src/scss/o-grid/_mixins.scss +384 -0
  19. package/src/scss/o-grid/_variables.scss +105 -0
  20. package/src/scss/o-grid/main.scss +5 -0
  21. package/src/scss/o-icons/_mixins.scss +71 -0
  22. package/src/scss/o-icons/main.scss +1 -0
  23. package/src/scss/o-normalise/_mixins.scss +126 -0
  24. package/src/scss/o-normalise/_variables.scss +10 -0
  25. package/src/scss/o-normalise/main.scss +4 -0
  26. package/src/scss/o-spacing/_variables.scss +29 -0
  27. package/src/scss/o-spacing/main.scss +28 -0
  28. package/src/scss/o-typography/main.scss +428 -0
  29. package/src/scss/o-visual-effects/main.scss +4 -0
  30. package/src/scss/o-visual-effects/scss/_shadows.scss +31 -0
  31. package/src/scss/o-visual-effects/scss/_variables.scss +13 -0
  32. package/src/scss/tokens/core.scss +563 -0
  33. package/src/scss/tokens/internal.scss +456 -0
  34. package/src/scss/tokens/professional.scss +537 -0
  35. package/src/scss/tokens/sustainable-views.scss +493 -0
  36. package/src/scss/tokens/whitelabel.scss +465 -0
package/README.md ADDED
@@ -0,0 +1,108 @@
1
+ # o-private-foundation
2
+
3
+ > :warning: NOTE: this package should ONLY be used in Origami components. If you are not developing a component that is part of Origami, please do not use this package.
4
+
5
+ A collection of Origami components for use in other Origami components.
6
+
7
+ - [Usage](#usage)
8
+ - [Behaviour](#behaviour)
9
+ - [Markup](#markup)
10
+ - [Sass](#sass)
11
+ - [JavaScript](#javascript)
12
+ - [Troubleshooting](#troubleshooting)
13
+ - [Contributing](#contributing)
14
+ - [Migration](#migration)
15
+ - [Contact](#contact)
16
+ - [Licence](#licence)
17
+
18
+ _Instructions for the component. We've broken this down by Markup, JavaScript, Sass, etc. You may add more sections as needed._
19
+
20
+ ## Usage
21
+
22
+ Check out [how to include Origami components in your project](https://origami.ft.com/docs/components/#including-components-in-your-project) to get started with `o-private-foundation`.
23
+
24
+ ## Behaviour
25
+
26
+ `o-private-foundation` Behaviour description.
27
+
28
+ ## Markup
29
+
30
+ _Markup documentation for the component. Including css classes, data attributes, and tags for variations of the component._
31
+ _Demo markup is also shown in the registry. For complex markup it can be useful to describe the markup and link to the registry demos for a full example._
32
+ _Remember to start your codeblocks with three backticks and "html" so your markup is syntax highlighted correctly._
33
+ ```html
34
+ <div data-o-component="o-private-foundation" class='o-private-foundation'>
35
+ </div>
36
+ ```
37
+
38
+ ## Sass
39
+
40
+ _Sass documentation. With instructions to include styles with a primary mixin, what options are available, brand support where applicable._
41
+ _For complex components it may be helpful to document apis with SassDoc and link to the components SassDoc in the Origami Registry._
42
+ _Remember to start your codeblocks with three backticks and "scss" so your markup is syntax highlighted correctly._
43
+
44
+ Use `@include oPrivateFoundation()` to include styles for all `o-private-foundation` features.
45
+
46
+ ```scss
47
+ @import "@financial-times/o-private-foundation";
48
+
49
+ @include oPrivateFoundation();
50
+ ```
51
+
52
+
53
+ ## JavaScript
54
+
55
+ _JavaScript documentation. Including how to initialise the component, available options, and common usecases._
56
+ _For complex components it may be helpful to document apis with JSDoc and link to the components JSDocs in the Origami Registry._
57
+ _Remember to start your codeblocks with three backticks and "js" so your js is syntax highlighted correctly._
58
+
59
+ JavaScript is initialised automatically for [Origami Build Service](https://www.ft.com/__origami/service/build/v2/) users. If your project is using a manual build process, [initialise `o-private-foundation` manually](https://origami.ft.com/docs/tutorials/manual-build/).
60
+
61
+ For example call the `init` method to initialise all `o-private-foundation` instances in the document:
62
+
63
+ ```js
64
+ import oPrivateFoundation from 'o-private-foundation';
65
+ oPrivateFoundation.init();
66
+ ```
67
+
68
+ Or pass an element to initialise a specific `o-private-foundation` instance:
69
+
70
+ ```js
71
+ import oPrivateFoundation from 'o-private-foundation';
72
+ const oPrivateFoundationElement = document.getElementById('#my-o-private-foundation-element');
73
+ oPrivateFoundation.init(oPrivateFoundationElement);
74
+ ```
75
+
76
+
77
+
78
+ ## Troubleshooting
79
+
80
+ _Answers to questions or problems that come up repeatedly._
81
+ _It's likely you can delete this section for now. Remember to remove it from the table of contents._
82
+
83
+ ## Contributing
84
+
85
+ _Contributing documentation for non typical components._
86
+ _It's likely you can delete this section if your component conforms with other components._
87
+ _Remember to update the table of contents is you remove this section._
88
+
89
+ ## Migration
90
+
91
+ _Guides to upgrade from one major version of a component to another._
92
+ _This section includes a table of major versions with links to `MIGRATION.md`._
93
+ _`MIGRATION.md` would provide upgrade instructions, but since this is a new component there is no `MIGRATION.md`._
94
+ _Delete this section, including from the table of contents, until there is a second major version of this component._
95
+
96
+ State | Major Version | Last Minor Release | Migration guide |
97
+ :---: | :---: | :---: | :---:
98
+ ✨ active | 3 | N/A | [migrate to v3](MIGRATION.md#migrating-from-v2-to-v3) |
99
+ ⚠ maintained | 2 | 2.0 | [migrate to v2](MIGRATION.md#migrating-from-v1-to-v2) |
100
+ ╳ deprecated | 1 | 1.0 | N/A |
101
+
102
+ ## Contact
103
+ If you have any questions or comments about this component, or need help using it, please either [raise an issue](https://github.com/Financial-Times/origami/issues/new?labels=o-private-foundation,components), visit [#origami-support](https://financialtimes.slack.com/messages/#origami-support/) or email [origami.support@ft.com](mailto:origami.support@ft.com).
104
+
105
+ ## Licence
106
+ This software is published by the Financial Times under the [MIT licence](http://opensource.org/licenses/MIT).
107
+ `;
108
+ };
File without changes
@@ -0,0 +1 @@
1
+ @import '../../main.scss';
package/main.js ADDED
@@ -0,0 +1,60 @@
1
+ /* eslint-disable no-console */
2
+ const missingDataMessage = 'Could not find layout information. ' +
3
+ 'You may need to include o-grid css. See the README (https://registry.origami.ft.com/components/o-grid/readme) ' +
4
+ 'for more information.';
5
+
6
+ /**
7
+ * Grab the current layout.
8
+ * CSS must be included so JavaScript can retrieve layout information.
9
+ * See the README for more information.
10
+ *
11
+ * @returns {string} Layout name
12
+ */
13
+ function getCurrentLayout() {
14
+ return getGridProperties().layout;
15
+ }
16
+
17
+ /**
18
+ * Grab grid properties
19
+ *
20
+ * @returns {object} layout names and gutter widths
21
+ */
22
+ function getGridProperties() {
23
+ const properties = getGridFromDoc('after');
24
+ if (Object.keys(properties).length === 0) {
25
+ console.warn(missingDataMessage);
26
+ }
27
+ return properties;
28
+ }
29
+
30
+ /**
31
+ * Grab grid properties surfaced in html:after and html:before's content
32
+ *
33
+ * @param {string} position Whether to get all properties in :before, or current properties in :after
34
+ * @returns {object} layout names and gutter widths
35
+ */
36
+ function getGridFromDoc(position) {
37
+ // Contained in a try/catch as it should not error if o-grid styles are not (deliberately or accidentally) loaded
38
+ // e.g. o-tracking will always try to read this property, but the page is not obliged to use o-grid for layout
39
+ try {
40
+ let gridProperties = window.getComputedStyle(document.documentElement, ':' + position).getPropertyValue('content');
41
+ // Firefox computes: "{\"foo\": \"bar\"}"
42
+ // We want readable JSON: {"foo": "bar"}
43
+ gridProperties = gridProperties.replace(/'/g, '').replace(/\\/g, '').replace(/^"/, '').replace(/"$/, '');
44
+ return JSON.parse(gridProperties);
45
+ } catch (e) {
46
+ return {};
47
+ }
48
+ }
49
+
50
+ const oPrivateGrid = {
51
+ getCurrentLayout,
52
+ };
53
+
54
+ export {
55
+ oPrivateGrid,
56
+ };
57
+
58
+ export default {
59
+ oPrivateGrid,
60
+ };
package/main.scss ADDED
@@ -0,0 +1,32 @@
1
+ @import './src/scss/brand';
2
+
3
+ @import './src/scss/variables';
4
+
5
+ @import './src/scss/o-spacing/main';
6
+ @import './src/scss/o-colors/main';
7
+ @import './src/scss/o-normalise/main';
8
+ @import "./src/scss/o-icons/main";
9
+ @import './src/scss/o-visual-effects/main';
10
+ @import './src/scss/o-buttons/main';
11
+ @import './src/scss/o-grid/main';
12
+ @import './src/scss/o-typography/main';
13
+
14
+ @mixin oPrivateFoundation() {
15
+ @font-face {
16
+ src: url('https://www.ft.com/__origami/service/build/v3/font?version=1.13&font_name=Metric2-VF&system_code=origami&font_format=woff2')
17
+ format('woff2-variations');
18
+ font-family: 'metric 2 VF';
19
+ font-weight: 300 800;
20
+ font-style: normal;
21
+ font-display: swap;
22
+ }
23
+
24
+ @font-face {
25
+ src: url('https://www.ft.com/__origami/service/build/v3/font?version=1.13&font_name=FinancierDisplay-VF&system_code=origami&font_format=woff2')
26
+ format('woff2-variations');
27
+ font-family: 'financier display VF';
28
+ font-weight: 300 800;
29
+ font-style: normal;
30
+ font-display: swap;
31
+ }
32
+ }
package/origami.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "origamiType": "component",
3
+ "origamiVersion": "2.0",
4
+ "brands": ["core", "internal", "whitelabel"],
5
+ "support": "https://github.com/Financial-Times/origami/issues/new?labels=o-private-foundation,components",
6
+ "supportContact": {
7
+ "email": "origami.support@ft.com",
8
+ "slack": "#origami-support"
9
+ },
10
+ "supportStatus": "experimental",
11
+ "browserFeatures": {},
12
+ "demosDefaults": {
13
+ "sass": "demos/src/demo.scss",
14
+ "template": "demos/src/demo.mustache",
15
+ "documentClasses": "",
16
+ "dependencies": []
17
+ },
18
+ "demos": [
19
+ {
20
+ "title": "A Useful Demo",
21
+ "name": "demo",
22
+ "template": "demos/src/demo.mustache",
23
+ "description": "Description of the demo"
24
+ }
25
+ ]
26
+ }
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@financial-times/o-private-foundation",
3
+ "version": "1.0.0",
4
+ "description": "Foundation components for use in Origami components only.",
5
+ "keywords": [],
6
+ "homepage": "https://registry.origami.ft.com/components/o-private-foundation",
7
+ "bugs": {
8
+ "url": "https://github.com/Financial-Times/origami/issues/new?labels=o-private-foundation,components",
9
+ "email": "origami.support@ft.com"
10
+ },
11
+ "license": "MIT",
12
+ "type": "module",
13
+ "scripts": {
14
+ "build": "bash ../../scripts/component/build.bash",
15
+ "test": "bash ../../scripts/component/test.bash",
16
+ "lint": "bash ../../scripts/component/lint.bash",
17
+ "watch": "bash ../../scripts/component/watch.bash"
18
+ },
19
+ "browser": "main.js",
20
+ "peerDependencies": {
21
+ "@financial-times/o-brand": "^4.1.0"
22
+ },
23
+ "devDependencies": {},
24
+ "engines": {
25
+ "npm": ">7"
26
+ },
27
+ "volta": {
28
+ "node": "14.16.1",
29
+ "npm": "7.11.1"
30
+ },
31
+ "percy": true,
32
+ "private": false
33
+ }
@@ -0,0 +1,68 @@
1
+ // Fetch tokens and use to configure brands
2
+ // following the existing Origami v2 pattern.
3
+ @use '_tokens.scss' as tokens;
4
+ @import '@financial-times/o-brand/main';
5
+ $o-private-foundation-tokens: tokens.forBrand(oBrandGetCurrent());
6
+
7
+ /// Helper for `o-brand` function.
8
+ @function oPrivateFoundationGet($variables, $from: null) {
9
+ $value: oBrandGet(
10
+ $component: 'o-private-foundation',
11
+ $variables: $variables,
12
+ $from: $from,
13
+ );
14
+ @if ($value == null) {
15
+ @error 'oPrivateFoundationGet: design token not found: #{$variables}';
16
+ }
17
+ @return $value;
18
+ }
19
+
20
+ /// Helper for `o-brand` function.
21
+ @function oPrivateFoundationSupports($variant) {
22
+ @return oBrandSupportsVariant(
23
+ $component: 'o-private-foundation',
24
+ $variant: $variant
25
+ );
26
+ }
27
+
28
+ @if oBrandIs('core') {
29
+ @include oBrandDefine(
30
+ 'o-private-foundation',
31
+ 'core',
32
+ (
33
+ 'variables':
34
+ map-merge(
35
+ $o-private-foundation-tokens,
36
+ (
37
+ // FT professional is treated as a theme in Origami v2.
38
+ 'professional': tokens.forBrand('professional')
39
+ )
40
+ ),
41
+ 'supports-variants': (
42
+ 'professional',
43
+ ),
44
+ )
45
+ );
46
+ }
47
+
48
+ @if oBrandIs('internal') {
49
+ @include oBrandDefine(
50
+ 'o-private-foundation',
51
+ 'internal',
52
+ (
53
+ 'variables': $o-private-foundation-tokens,
54
+ 'supports-variants': (),
55
+ )
56
+ );
57
+ }
58
+
59
+ @if oBrandIs('whitelabel') {
60
+ @include oBrandDefine(
61
+ 'o-private-foundation',
62
+ 'whitelabel',
63
+ (
64
+ 'variables': $o-private-foundation-tokens,
65
+ 'supports-variants': (),
66
+ )
67
+ );
68
+ }
@@ -0,0 +1,15 @@
1
+ @use 'tokens/core.scss' as coreTokens;
2
+ @use 'tokens/professional.scss' as professionalTokens;
3
+ @use 'tokens/internal.scss' as internalTokens;
4
+ @use 'tokens/whitelabel.scss' as whitelabelTokens;
5
+
6
+ $_by-brand: (
7
+ 'core': coreTokens.$tokens,
8
+ 'professional': professionalTokens.$tokens,
9
+ 'internal': internalTokens.$tokens,
10
+ 'whitelabel': whitelabelTokens.$tokens,
11
+ );
12
+
13
+ @function forBrand($brand) {
14
+ @return map-get($_by-brand, $brand);
15
+ }
@@ -0,0 +1 @@
1
+ // Add any global Sass variables for o-private-foundation here.