ember-freestyle 0.16.0-beta.0 → 0.17.0-alpha-css-vars-api.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.
- package/CHANGELOG.md +9 -0
- package/addon/components/freestyle/usage/basic-css-variable/index.hbs +34 -0
- package/addon/components/freestyle/usage/basic-css-variable/index.ts +28 -0
- package/addon/components/freestyle/usage/index.hbs +26 -0
- package/addon/components/freestyle/usage/index.ts +5 -0
- package/addon/decorators/css-variable.ts +155 -0
- package/addon/glint.ts +3 -0
- package/addon/index.ts +2 -0
- package/addon/utils/css-rules.ts +61 -0
- package/app/components/freestyle/usage/basic-css-variable.js +1 -0
- package/app/styles/components/freestyle/usage.scss +12 -4
- package/app/styles/components/freestyle-guide.scss +4 -0
- package/components/freestyle/usage/basic-css-variable/index.d.ts +19 -0
- package/components/freestyle/usage/index.d.ts +5 -0
- package/decorators/css-variable.d.ts +24 -0
- package/glint.d.ts +3 -0
- package/index.d.ts +2 -0
- package/package.json +3 -1
- package/types/global.d.ts +6 -1
- package/utils/css-rules.d.ts +2 -0
- package/vendor/ember-freestyle.css +27 -13
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
|
|
8
|
+
## v0.17.0-alpha-css-vars-api.0 (2022-10-17)
|
|
9
|
+
|
|
10
|
+
#### :rocket: Enhancement
|
|
11
|
+
* [#856](https://github.com/chrislopresto/ember-freestyle/pull/856) Make the navigation menu sticky ([@bertdeblock](https://github.com/bertdeblock))
|
|
12
|
+
|
|
13
|
+
#### Committers: 1
|
|
14
|
+
- Bert De Block ([@bertdeblock](https://github.com/bertdeblock))
|
|
15
|
+
|
|
7
16
|
## v0.16.0-beta.0 (2022-09-22)
|
|
8
17
|
|
|
9
18
|
#### :boom: Breaking Change
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<tr class="FreestyleUsageCssVar">
|
|
2
|
+
<td class="FreestyleUsageCssVar-name">
|
|
3
|
+
{{@name}}
|
|
4
|
+
</td>
|
|
5
|
+
|
|
6
|
+
<td class="FreestyleUsageCssVar-description">
|
|
7
|
+
<span class="FreestyleUsageCssVar-type u-codePill">
|
|
8
|
+
{{@type}}
|
|
9
|
+
</span>
|
|
10
|
+
|
|
11
|
+
{{@description}}
|
|
12
|
+
</td>
|
|
13
|
+
|
|
14
|
+
<td class="FreestyleUsageCssVar-details">
|
|
15
|
+
{{#if this.shouldRenderDefaultValue}}
|
|
16
|
+
<span class="FreestyleUsageCssVar-default u-codePill">
|
|
17
|
+
{{@defaultValue.raw}}
|
|
18
|
+
</span>
|
|
19
|
+
{{#if this.shouldRenderDefaultComputed}}
|
|
20
|
+
({{@defaultValue.computed}})
|
|
21
|
+
{{/if}}
|
|
22
|
+
{{/if}}
|
|
23
|
+
</td>
|
|
24
|
+
|
|
25
|
+
<td class="FreestyleUsageCssVar-controls FreestyleUsageCssVar-controls--string">
|
|
26
|
+
{{#unless @hideControls}}
|
|
27
|
+
<Freestyle::Usage::String::Control
|
|
28
|
+
@options={{@options}}
|
|
29
|
+
@value={{@value}}
|
|
30
|
+
@onInput={{@onInput}}
|
|
31
|
+
/>
|
|
32
|
+
{{/unless}}
|
|
33
|
+
</td>
|
|
34
|
+
</tr>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { type CSSVariableDefaults } from 'ember-freestyle';
|
|
3
|
+
|
|
4
|
+
interface Signature {
|
|
5
|
+
Args: {
|
|
6
|
+
name?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
defaultValue?: CSSVariableDefaults;
|
|
9
|
+
type?: string;
|
|
10
|
+
hideControls?: boolean;
|
|
11
|
+
value?: string;
|
|
12
|
+
options?: string[];
|
|
13
|
+
onInput: (val: string | null | undefined) => void;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default class FreestyleUsageBasicCssVariableComponent extends Component<Signature> {
|
|
18
|
+
get shouldRenderDefaultValue(): boolean {
|
|
19
|
+
return this.args.defaultValue !== undefined;
|
|
20
|
+
}
|
|
21
|
+
get shouldRenderDefaultComputed(): boolean {
|
|
22
|
+
const { defaultValue } = this.args;
|
|
23
|
+
return (
|
|
24
|
+
defaultValue?.computed !== undefined &&
|
|
25
|
+
defaultValue.computed !== defaultValue.raw
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -56,6 +56,32 @@
|
|
|
56
56
|
{{/if}}
|
|
57
57
|
{{/if}}
|
|
58
58
|
|
|
59
|
+
{{#if (has-block 'cssVars')}}
|
|
60
|
+
{{#if this.showApi}}
|
|
61
|
+
<div class="FreestyleUsage-cssVars">
|
|
62
|
+
<h3 class="FreestyleUsage-cssVarsTitle">CSS Variables API</h3>
|
|
63
|
+
|
|
64
|
+
<table class="FreestyleUsage-cssVarsTable">
|
|
65
|
+
<thead>
|
|
66
|
+
<tr>
|
|
67
|
+
<th>Variable</th>
|
|
68
|
+
<th>Description</th>
|
|
69
|
+
<th>Default</th>
|
|
70
|
+
<th>Value</th>
|
|
71
|
+
</tr>
|
|
72
|
+
</thead>
|
|
73
|
+
<tbody>
|
|
74
|
+
{{yield
|
|
75
|
+
(hash
|
|
76
|
+
Basic=(component 'freestyle/usage/basic-css-variable' )
|
|
77
|
+
)
|
|
78
|
+
to="cssVars"}}
|
|
79
|
+
</tbody>
|
|
80
|
+
</table>
|
|
81
|
+
</div>
|
|
82
|
+
{{/if}}
|
|
83
|
+
{{/if}}
|
|
84
|
+
|
|
59
85
|
{{#if this.showSource}}
|
|
60
86
|
<div class="FreestyleUsage-sourceContainer" {{did-insert this.highlightSource}}>
|
|
61
87
|
<FreestyleSource @source={{@source}} />
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { dasherize } from '@ember/string';
|
|
3
|
+
import { tracked } from '@glimmer/tracking';
|
|
4
|
+
import { action } from '@ember/object';
|
|
5
|
+
import {
|
|
6
|
+
getComputedValueForCssVariable as cssVarComputedValue,
|
|
7
|
+
getCssVariableDefinition as cssVarAuthoredValue,
|
|
8
|
+
} from 'ember-freestyle/utils/css-rules';
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
This decorator defines a property returning a CssVariableInfo instance.
|
|
12
|
+
|
|
13
|
+
The options accepted by the decorator are:
|
|
14
|
+
|
|
15
|
+
cssClassName: string;
|
|
16
|
+
toVariableName: (propertyName: string) => string;
|
|
17
|
+
|
|
18
|
+
The toVariableName option is used to converts the property name to a
|
|
19
|
+
a css variable name. The default implementation of this callback dasherizes
|
|
20
|
+
the property name to get the css variable name.
|
|
21
|
+
|
|
22
|
+
The default value (both authored and computed) is looked up on the
|
|
23
|
+
selector specified by options.cssClassName and a CSSVariableInfo is
|
|
24
|
+
initialized and returned.
|
|
25
|
+
|
|
26
|
+
If options.cssClassName is not specified, the decorator will try to read
|
|
27
|
+
a `cssClassName` property from the object with the decorated property.
|
|
28
|
+
If this is also not present, an error will be thrown.
|
|
29
|
+
|
|
30
|
+
The overloads defined here are needed to handle both the no-args decorator usage
|
|
31
|
+
as well as the version with parentheses. e.g.
|
|
32
|
+
|
|
33
|
+
@cssVariable declare fooColor: CSSVariableInfo;
|
|
34
|
+
@cssVariable({ cssClassName: 'Foo' }) declare fooColor: CSSVariableInfo;
|
|
35
|
+
*/
|
|
36
|
+
export function cssVariable(target: TargetInstance, key: string): any;
|
|
37
|
+
export function cssVariable(options: Partial<CSSVariableDecoratorOptions>): any;
|
|
38
|
+
export function cssVariable(
|
|
39
|
+
targetOrOptions: TargetInstance | CSSVariableDecoratorOptions,
|
|
40
|
+
key?: string
|
|
41
|
+
): any {
|
|
42
|
+
if (typeof key === 'string') {
|
|
43
|
+
return {
|
|
44
|
+
get(): CSSVariableInfo {
|
|
45
|
+
const options = prepareOptions(this, {});
|
|
46
|
+
return getCssVariableInfoMemoized(this, key, options);
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
} else {
|
|
50
|
+
return function (_target: TargetInstance, key: string) {
|
|
51
|
+
return {
|
|
52
|
+
get(this: TargetInstance): CSSVariableInfo {
|
|
53
|
+
let options = targetOrOptions as CSSVariableDecoratorOptions;
|
|
54
|
+
options = prepareOptions(this, options);
|
|
55
|
+
return getCssVariableInfoMemoized(this, key, options);
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface CSSVariableDefaults {
|
|
63
|
+
raw: string | undefined;
|
|
64
|
+
computed: string | undefined;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export class CSSVariableInfo {
|
|
68
|
+
name: string;
|
|
69
|
+
defaults: CSSVariableDefaults;
|
|
70
|
+
@tracked value: string | undefined;
|
|
71
|
+
|
|
72
|
+
constructor(variableName: string, cssClassName: string) {
|
|
73
|
+
this.name = variableName;
|
|
74
|
+
|
|
75
|
+
let raw = cssVarAuthoredValue(variableName, '.' + cssClassName);
|
|
76
|
+
raw = raw?.trim() ?? undefined;
|
|
77
|
+
|
|
78
|
+
let computed = cssVarComputedValue(variableName, cssClassName);
|
|
79
|
+
computed = computed?.trim() ?? undefined;
|
|
80
|
+
|
|
81
|
+
this.defaults = {
|
|
82
|
+
raw,
|
|
83
|
+
computed,
|
|
84
|
+
};
|
|
85
|
+
this.value = raw ?? computed;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@action
|
|
89
|
+
update(val: string) {
|
|
90
|
+
this.value = val;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// we use a WeakMap in order to allow target instances to be garbage-collected
|
|
95
|
+
const memoizationMap = new WeakMap<
|
|
96
|
+
TargetInstance,
|
|
97
|
+
Map<string, CSSVariableInfo>
|
|
98
|
+
>();
|
|
99
|
+
|
|
100
|
+
interface TargetInstance {
|
|
101
|
+
constructor: { name: string };
|
|
102
|
+
cssClassName?: string;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
interface CSSVariableDecoratorOptions {
|
|
106
|
+
toVariableName: (propertyName: string) => string;
|
|
107
|
+
cssClassName: string; // the CSS class name to use to read the default value of the variable from
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function getCssVariableInfoMemoized(
|
|
111
|
+
target: TargetInstance,
|
|
112
|
+
key: string,
|
|
113
|
+
options: CSSVariableDecoratorOptions
|
|
114
|
+
): CSSVariableInfo {
|
|
115
|
+
if (!memoizationMap.get(target)) {
|
|
116
|
+
memoizationMap.set(target, new Map());
|
|
117
|
+
}
|
|
118
|
+
const memoizedInfos = memoizationMap.get(target);
|
|
119
|
+
if (memoizedInfos) {
|
|
120
|
+
let result = memoizedInfos.get(key);
|
|
121
|
+
if (!result) {
|
|
122
|
+
const name = options.toVariableName(key);
|
|
123
|
+
result = new CSSVariableInfo(name, options.cssClassName);
|
|
124
|
+
memoizedInfos.set(key, result);
|
|
125
|
+
}
|
|
126
|
+
return result;
|
|
127
|
+
} else {
|
|
128
|
+
throw new Error(
|
|
129
|
+
'Unexpected missing key in cssVariable decorator implementation'
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function prepareOptions(
|
|
135
|
+
targetInstance: TargetInstance,
|
|
136
|
+
userSpecifiedOptions: Partial<CSSVariableDecoratorOptions>
|
|
137
|
+
): CSSVariableDecoratorOptions {
|
|
138
|
+
let options = userSpecifiedOptions;
|
|
139
|
+
if (!options.cssClassName) {
|
|
140
|
+
const cssClassName = targetInstance['cssClassName'];
|
|
141
|
+
if (!cssClassName) {
|
|
142
|
+
throw new Error(
|
|
143
|
+
'Must specify `cssClassName` as an option to @cssVariable decorator or define `cssClassName` on the class owning the decorated property'
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
options = Object.assign({}, options, { cssClassName });
|
|
147
|
+
}
|
|
148
|
+
return Object.assign(
|
|
149
|
+
{
|
|
150
|
+
toVariableName: dasherize,
|
|
151
|
+
},
|
|
152
|
+
options as Pick<CSSVariableDecoratorOptions, 'cssClassName'> &
|
|
153
|
+
Partial<CSSVariableDecoratorOptions>
|
|
154
|
+
);
|
|
155
|
+
}
|
package/addon/glint.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type FreestyleUsage from 'ember-freestyle/components/freestyle/usage';
|
|
2
2
|
import type FreestyleUsageArgument from 'ember-freestyle/components/freestyle/usage/argument';
|
|
3
3
|
import type FreestyleUsageArray from 'ember-freestyle/components/freestyle/usage/array';
|
|
4
|
+
import type FreestyleUsageBasicCssVariable from 'ember-freestyle/components/freestyle/usage/basic-css-variable';
|
|
4
5
|
import type FreestyleUsageBool from 'ember-freestyle/components/freestyle/usage/bool';
|
|
5
6
|
import type FreestyleUsageBoolControl from 'ember-freestyle/components/freestyle/usage/bool/control';
|
|
6
7
|
import type FreestyleUsageNumber from 'ember-freestyle/components/freestyle/usage/number';
|
|
@@ -40,6 +41,8 @@ declare module '@glint/environment-ember-loose/registry' {
|
|
|
40
41
|
'freestyle/usage/bool': typeof FreestyleUsageBool;
|
|
41
42
|
'Freestyle::Usage::Bool::Control': typeof FreestyleUsageBoolControl;
|
|
42
43
|
'Freestyle::Usage::Number': typeof FreestyleUsageNumber;
|
|
44
|
+
'Freestyle::Usage::BasicCssVariable': typeof FreestyleUsageBasicCssVariable;
|
|
45
|
+
'freestyle/usage/basic-css-variable': typeof FreestyleUsageBasicCssVariable;
|
|
43
46
|
'freestyle/usage/number': typeof FreestyleUsageNumber;
|
|
44
47
|
'Freestyle::Usage::Number::Control': typeof FreestyleUsageNumberControl;
|
|
45
48
|
'Freestyle::Usage::Object': typeof FreestyleUsageObject;
|
package/addon/index.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// module-scope variable to cache an array of all our readable CSS rules
|
|
2
|
+
let allRules: CSSRule[] | undefined;
|
|
3
|
+
|
|
4
|
+
function getReadableCssRules(): CSSRule[] {
|
|
5
|
+
if (!allRules) {
|
|
6
|
+
allRules = Array.from(document.styleSheets)
|
|
7
|
+
.map((ss: CSSStyleSheet) => {
|
|
8
|
+
try {
|
|
9
|
+
return ss.cssRules;
|
|
10
|
+
} catch (e) {
|
|
11
|
+
// Not all stylesheets allow you to access the rules. The restrictions generally match CORS rules.
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
.filter(Boolean)
|
|
16
|
+
.flatMap((rules: CSSRuleList) => Array.from(rules));
|
|
17
|
+
}
|
|
18
|
+
return allRules;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function getStyleDeclarations(selector: string): CSSStyleDeclaration[] {
|
|
22
|
+
return getReadableCssRules()
|
|
23
|
+
.filter((rule: CSSStyleRule) => rule.selectorText === selector)
|
|
24
|
+
.flatMap((rule: CSSStyleRule) => rule.style);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function getCssVariableDefinition(
|
|
28
|
+
variableName: string,
|
|
29
|
+
selector: string
|
|
30
|
+
): string {
|
|
31
|
+
// find the last declaration of the selector that contains a value
|
|
32
|
+
// for the CSS variable we're interested in
|
|
33
|
+
const styleDeclaration = getStyleDeclarations(selector)
|
|
34
|
+
.filter((sd) => sd.getPropertyValue(`--${variableName}`))
|
|
35
|
+
.reverse()[0];
|
|
36
|
+
|
|
37
|
+
// return the value as defined in this declaration
|
|
38
|
+
return styleDeclaration?.getPropertyValue(`--${variableName}`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function getComputedValueForCssVariable(
|
|
42
|
+
variableName: string,
|
|
43
|
+
cssClassName: string
|
|
44
|
+
): string {
|
|
45
|
+
let element = document.querySelector('.' + cssClassName);
|
|
46
|
+
let tempElement;
|
|
47
|
+
if (!element) {
|
|
48
|
+
// if an element with the specified classname is not present
|
|
49
|
+
// in the DOM, create a temporary one that we can use to read
|
|
50
|
+
// the computed property value
|
|
51
|
+
tempElement = document.createElement('div');
|
|
52
|
+
tempElement.className = cssClassName;
|
|
53
|
+
document.body.appendChild(tempElement);
|
|
54
|
+
element = tempElement;
|
|
55
|
+
}
|
|
56
|
+
const result = getComputedStyle(element).getPropertyValue(
|
|
57
|
+
`--${variableName}`
|
|
58
|
+
);
|
|
59
|
+
tempElement?.remove();
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from 'ember-freestyle/components/freestyle/usage/basic-css-variable';
|
|
@@ -20,7 +20,12 @@
|
|
|
20
20
|
color: #666;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
&-
|
|
23
|
+
&-api + &-cssVars {
|
|
24
|
+
margin-top: 1rem;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&-apiTitle,
|
|
28
|
+
&-cssVarsTitle {
|
|
24
29
|
font-size: 0.9rem;
|
|
25
30
|
font-weight: bold;
|
|
26
31
|
margin: 0;
|
|
@@ -53,12 +58,14 @@
|
|
|
53
58
|
}
|
|
54
59
|
|
|
55
60
|
&-sourceContainer,
|
|
56
|
-
&-apiTable
|
|
61
|
+
&-apiTable,
|
|
62
|
+
&-cssVarsTable {
|
|
57
63
|
margin-left: -1rem;
|
|
58
64
|
margin-right: -1rem;
|
|
59
65
|
}
|
|
60
66
|
|
|
61
|
-
&-apiTable
|
|
67
|
+
&-apiTable,
|
|
68
|
+
&-cssVarsTable {
|
|
62
69
|
width: 100%;
|
|
63
70
|
padding: 0.5rem 0 0.2rem;
|
|
64
71
|
border-collapse: collapse;
|
|
@@ -90,7 +97,8 @@
|
|
|
90
97
|
/*
|
|
91
98
|
FreestyleUsageArgument
|
|
92
99
|
*/
|
|
93
|
-
.FreestyleUsageArgument
|
|
100
|
+
.FreestyleUsageArgument,
|
|
101
|
+
.FreestyleUsageCssVar {
|
|
94
102
|
font-size: 0.8rem;
|
|
95
103
|
|
|
96
104
|
&-name {
|
|
@@ -92,8 +92,12 @@ $FreestyleGuide-boxShadow: 0 2px 5px 0 $FreestyleGuide-shadow1,
|
|
|
92
92
|
|
|
93
93
|
&-nav {
|
|
94
94
|
background-color: $FreestyleGuide-color--background;
|
|
95
|
+
height: 100vh;
|
|
95
96
|
order: -1;
|
|
97
|
+
overflow: auto;
|
|
96
98
|
padding: 1rem;
|
|
99
|
+
position: sticky;
|
|
100
|
+
top: 0;
|
|
97
101
|
|
|
98
102
|
@include freestyle-breakpoint(large) {
|
|
99
103
|
border-right: solid 1px $FreestyleGuide-color--secondary;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { type CSSVariableDefaults } from 'ember-freestyle';
|
|
3
|
+
interface Signature {
|
|
4
|
+
Args: {
|
|
5
|
+
name?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
defaultValue?: CSSVariableDefaults;
|
|
8
|
+
type?: string;
|
|
9
|
+
hideControls?: boolean;
|
|
10
|
+
value?: string;
|
|
11
|
+
options?: string[];
|
|
12
|
+
onInput: (val: string | null | undefined) => void;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export default class FreestyleUsageBasicCssVariableComponent extends Component<Signature> {
|
|
16
|
+
get shouldRenderDefaultValue(): boolean;
|
|
17
|
+
get shouldRenderDefaultComputed(): boolean;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare function cssVariable(target: TargetInstance, key: string): any;
|
|
2
|
+
export declare function cssVariable(options: Partial<CSSVariableDecoratorOptions>): any;
|
|
3
|
+
export interface CSSVariableDefaults {
|
|
4
|
+
raw: string | undefined;
|
|
5
|
+
computed: string | undefined;
|
|
6
|
+
}
|
|
7
|
+
export declare class CSSVariableInfo {
|
|
8
|
+
name: string;
|
|
9
|
+
defaults: CSSVariableDefaults;
|
|
10
|
+
value: string | undefined;
|
|
11
|
+
constructor(variableName: string, cssClassName: string);
|
|
12
|
+
update(val: string): void;
|
|
13
|
+
}
|
|
14
|
+
interface TargetInstance {
|
|
15
|
+
constructor: {
|
|
16
|
+
name: string;
|
|
17
|
+
};
|
|
18
|
+
cssClassName?: string;
|
|
19
|
+
}
|
|
20
|
+
interface CSSVariableDecoratorOptions {
|
|
21
|
+
toVariableName: (propertyName: string) => string;
|
|
22
|
+
cssClassName: string;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
package/glint.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type FreestyleUsage from 'ember-freestyle/components/freestyle/usage';
|
|
2
2
|
import type FreestyleUsageArgument from 'ember-freestyle/components/freestyle/usage/argument';
|
|
3
3
|
import type FreestyleUsageArray from 'ember-freestyle/components/freestyle/usage/array';
|
|
4
|
+
import type FreestyleUsageBasicCssVariable from 'ember-freestyle/components/freestyle/usage/basic-css-variable';
|
|
4
5
|
import type FreestyleUsageBool from 'ember-freestyle/components/freestyle/usage/bool';
|
|
5
6
|
import type FreestyleUsageBoolControl from 'ember-freestyle/components/freestyle/usage/bool/control';
|
|
6
7
|
import type FreestyleUsageNumber from 'ember-freestyle/components/freestyle/usage/number';
|
|
@@ -39,6 +40,8 @@ declare module '@glint/environment-ember-loose/registry' {
|
|
|
39
40
|
'freestyle/usage/bool': typeof FreestyleUsageBool;
|
|
40
41
|
'Freestyle::Usage::Bool::Control': typeof FreestyleUsageBoolControl;
|
|
41
42
|
'Freestyle::Usage::Number': typeof FreestyleUsageNumber;
|
|
43
|
+
'Freestyle::Usage::BasicCssVariable': typeof FreestyleUsageBasicCssVariable;
|
|
44
|
+
'freestyle/usage/basic-css-variable': typeof FreestyleUsageBasicCssVariable;
|
|
42
45
|
'freestyle/usage/number': typeof FreestyleUsageNumber;
|
|
43
46
|
'Freestyle::Usage::Number::Control': typeof FreestyleUsageNumberControl;
|
|
44
47
|
'Freestyle::Usage::Object': typeof FreestyleUsageObject;
|
package/index.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-freestyle",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0-alpha-css-vars-api.0",
|
|
4
4
|
"description": "Create a living styleguide for your Ember app.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -97,6 +97,7 @@
|
|
|
97
97
|
"ember-cli-inject-live-reload": "^2.1.0",
|
|
98
98
|
"ember-cli-sass": "^11.0.1",
|
|
99
99
|
"ember-cli-sri": "^2.1.1",
|
|
100
|
+
"ember-cli-string-helpers": "^6.1.0",
|
|
100
101
|
"ember-cli-terser": "^4.0.2",
|
|
101
102
|
"ember-cli-typescript-blueprints": "^3.0.0",
|
|
102
103
|
"ember-code-snippet": "^3.0.0",
|
|
@@ -106,6 +107,7 @@
|
|
|
106
107
|
"ember-resolver": "^8.0.3",
|
|
107
108
|
"ember-source": "~4.7.0",
|
|
108
109
|
"ember-source-channel-url": "^3.0.0",
|
|
110
|
+
"ember-style-modifier": "^0.8.0",
|
|
109
111
|
"ember-template-imports": "^3.1.1",
|
|
110
112
|
"ember-template-lint": "^4.14.0",
|
|
111
113
|
"ember-try": "^2.0.0",
|
package/types/global.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ import '@glint/environment-ember-loose';
|
|
|
3
3
|
import AndHelper from 'ember-truth-helpers/helpers/and';
|
|
4
4
|
import EqHelper from 'ember-truth-helpers/helpers/eq';
|
|
5
5
|
import NotHelper from 'ember-truth-helpers/helpers/not';
|
|
6
|
-
import { ModifierLike } from '@glint/template';
|
|
6
|
+
import { HelperLike, ModifierLike } from '@glint/template';
|
|
7
|
+
import { SafeString } from '@ember/template/-private/handlebars';
|
|
7
8
|
|
|
8
9
|
declare module '@glint/environment-ember-loose/registry' {
|
|
9
10
|
export default interface Registry {
|
|
@@ -15,5 +16,9 @@ declare module '@glint/environment-ember-loose/registry' {
|
|
|
15
16
|
}>;
|
|
16
17
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
18
|
'focus-trap': ModifierLike<{ Args: { Named: any } }>;
|
|
19
|
+
'html-safe': HelperLike<{
|
|
20
|
+
Args: { Positional: [string] };
|
|
21
|
+
Return: SafeString;
|
|
22
|
+
}>;
|
|
18
23
|
}
|
|
19
24
|
}
|
|
@@ -69,8 +69,12 @@
|
|
|
69
69
|
}
|
|
70
70
|
.FreestyleGuide-nav {
|
|
71
71
|
background-color: #fff;
|
|
72
|
+
height: 100vh;
|
|
72
73
|
order: -1;
|
|
74
|
+
overflow: auto;
|
|
73
75
|
padding: 1rem;
|
|
76
|
+
position: sticky;
|
|
77
|
+
top: 0;
|
|
74
78
|
}
|
|
75
79
|
@media (min-width: 600px) {
|
|
76
80
|
.FreestyleGuide-nav {
|
|
@@ -383,7 +387,10 @@ END-FREESTYLE-USAGE */
|
|
|
383
387
|
font-size: 1.1rem;
|
|
384
388
|
color: #666;
|
|
385
389
|
}
|
|
386
|
-
.FreestyleUsage-
|
|
390
|
+
.FreestyleUsage-api + .FreestyleUsage-cssVars {
|
|
391
|
+
margin-top: 1rem;
|
|
392
|
+
}
|
|
393
|
+
.FreestyleUsage-apiTitle, .FreestyleUsage-cssVarsTitle {
|
|
387
394
|
font-size: 0.9rem;
|
|
388
395
|
font-weight: bold;
|
|
389
396
|
margin: 0;
|
|
@@ -411,30 +418,31 @@ END-FREESTYLE-USAGE */
|
|
|
411
418
|
display: block;
|
|
412
419
|
border-radius: 0 0 0 var(--radius);
|
|
413
420
|
}
|
|
414
|
-
.FreestyleUsage-sourceContainer, .FreestyleUsage-apiTable {
|
|
421
|
+
.FreestyleUsage-sourceContainer, .FreestyleUsage-apiTable, .FreestyleUsage-cssVarsTable {
|
|
415
422
|
margin-left: -1rem;
|
|
416
423
|
margin-right: -1rem;
|
|
417
424
|
}
|
|
418
|
-
.FreestyleUsage-apiTable {
|
|
425
|
+
.FreestyleUsage-apiTable, .FreestyleUsage-cssVarsTable {
|
|
419
426
|
width: 100%;
|
|
420
427
|
padding: 0.5rem 0 0.2rem;
|
|
421
428
|
border-collapse: collapse;
|
|
422
429
|
}
|
|
423
|
-
.FreestyleUsage-apiTable th {
|
|
430
|
+
.FreestyleUsage-apiTable th, .FreestyleUsage-cssVarsTable th {
|
|
424
431
|
text-align: left;
|
|
425
432
|
font-size: 0.8rem;
|
|
426
433
|
font-weight: 600;
|
|
427
434
|
color: #777;
|
|
428
435
|
}
|
|
429
|
-
.FreestyleUsage-apiTable tr {
|
|
436
|
+
.FreestyleUsage-apiTable tr, .FreestyleUsage-cssVarsTable tr {
|
|
430
437
|
border-bottom: 1px solid var(--border-color);
|
|
431
438
|
vertical-align: top;
|
|
432
439
|
}
|
|
433
|
-
.FreestyleUsage-apiTable tr:nth-child(even) {
|
|
440
|
+
.FreestyleUsage-apiTable tr:nth-child(even), .FreestyleUsage-cssVarsTable tr:nth-child(even) {
|
|
434
441
|
background-color: #f9f9f9;
|
|
435
442
|
}
|
|
436
443
|
.FreestyleUsage-apiTable th,
|
|
437
|
-
.FreestyleUsage-apiTable td
|
|
444
|
+
.FreestyleUsage-apiTable td, .FreestyleUsage-cssVarsTable th,
|
|
445
|
+
.FreestyleUsage-cssVarsTable td {
|
|
438
446
|
padding: 0.5rem 1rem;
|
|
439
447
|
}
|
|
440
448
|
.FreestyleUsage-sourceContainer {
|
|
@@ -444,24 +452,30 @@ END-FREESTYLE-USAGE */
|
|
|
444
452
|
/*
|
|
445
453
|
FreestyleUsageArgument
|
|
446
454
|
*/
|
|
447
|
-
.FreestyleUsageArgument
|
|
455
|
+
.FreestyleUsageArgument,
|
|
456
|
+
.FreestyleUsageCssVar {
|
|
448
457
|
font-size: 0.8rem;
|
|
449
458
|
}
|
|
450
|
-
.FreestyleUsageArgument-name
|
|
459
|
+
.FreestyleUsageArgument-name,
|
|
460
|
+
.FreestyleUsageCssVar-name {
|
|
451
461
|
font-weight: bold;
|
|
452
462
|
width: 20%;
|
|
453
463
|
}
|
|
454
|
-
.FreestyleUsageArgument-description
|
|
464
|
+
.FreestyleUsageArgument-description,
|
|
465
|
+
.FreestyleUsageCssVar-description {
|
|
455
466
|
width: 40%;
|
|
456
467
|
}
|
|
457
|
-
.FreestyleUsageArgument-required
|
|
468
|
+
.FreestyleUsageArgument-required,
|
|
469
|
+
.FreestyleUsageCssVar-required {
|
|
458
470
|
color: #d81c38;
|
|
459
471
|
font-style: oblique;
|
|
460
472
|
}
|
|
461
|
-
.FreestyleUsageArgument-default
|
|
473
|
+
.FreestyleUsageArgument-default,
|
|
474
|
+
.FreestyleUsageCssVar-default {
|
|
462
475
|
font-family: monospace;
|
|
463
476
|
}
|
|
464
|
-
.FreestyleUsageArgument-jsonViewer
|
|
477
|
+
.FreestyleUsageArgument-jsonViewer,
|
|
478
|
+
.FreestyleUsageCssVar-jsonViewer {
|
|
465
479
|
background-color: #222;
|
|
466
480
|
min-width: 300px;
|
|
467
481
|
padding: 1rem;
|