@udixio/theme 1.0.0-beta.16 → 1.0.0-beta.17
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/dist/plugin/plugin.abstract.d.ts +2 -1
- package/dist/plugin/plugin.service.d.ts +3 -1
- package/dist/plugins/font/font.plugin.d.ts +38 -0
- package/dist/plugins/tailwind/index.d.ts +1 -1
- package/dist/plugins/tailwind/plugins-tailwind/font.d.ts +5 -0
- package/dist/plugins/tailwind/{Tailwind.plugin.d.ts → tailwind.plugin.d.ts} +3 -0
- package/dist/theme.cjs.development.js +236 -12
- package/dist/theme.cjs.development.js.map +1 -1
- package/dist/theme.cjs.production.min.js +1 -1
- package/dist/theme.cjs.production.min.js.map +1 -1
- package/dist/theme.esm.js +236 -12
- package/dist/theme.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/plugin/plugin.abstract.ts +2 -1
- package/src/plugin/plugin.service.ts +23 -5
- package/src/plugins/font/font.plugin.ts +172 -0
- package/src/plugins/tailwind/index.ts +1 -1
- package/src/plugins/tailwind/main.ts +1 -1
- package/src/plugins/tailwind/plugins-tailwind/font.ts +69 -0
- package/src/plugins/tailwind/{Tailwind.plugin.ts → tailwind.plugin.ts} +9 -2
package/dist/theme.esm.js
CHANGED
|
@@ -1588,11 +1588,23 @@ var PluginService = /*#__PURE__*/function () {
|
|
|
1588
1588
|
};
|
|
1589
1589
|
_proto.loadPlugins = function loadPlugins(appService) {
|
|
1590
1590
|
var _this = this;
|
|
1591
|
-
this.pluginConstructors
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1591
|
+
var plugins = new Map(this.pluginConstructors);
|
|
1592
|
+
var size = 0;
|
|
1593
|
+
do {
|
|
1594
|
+
size = plugins.size;
|
|
1595
|
+
plugins.forEach(function (_ref, key) {
|
|
1596
|
+
var plugin = _ref[0],
|
|
1597
|
+
option = _ref[1];
|
|
1598
|
+
var deps = plugin.dependencies.filter(function (dep) {
|
|
1599
|
+
return !_this.pluginInstances.has(dep.name);
|
|
1600
|
+
});
|
|
1601
|
+
if (deps.length === 0) {
|
|
1602
|
+
_this.pluginInstances.set(plugin.name, new plugin(appService, option));
|
|
1603
|
+
plugins["delete"](key);
|
|
1604
|
+
}
|
|
1605
|
+
});
|
|
1606
|
+
} while (plugins.size != 0 && plugins.size < size);
|
|
1607
|
+
if (plugins.size > 0) console.log("Some plugins couldn't be loaded due to missing dependencies: ", Array.from(plugins.keys()));
|
|
1596
1608
|
};
|
|
1597
1609
|
_proto.getPlugin = function getPlugin(plugin) {
|
|
1598
1610
|
var pluginInstance = this.pluginInstances.get(plugin.name);
|
|
@@ -1632,7 +1644,7 @@ function bootstrapFromConfig(path) {
|
|
|
1632
1644
|
}
|
|
1633
1645
|
|
|
1634
1646
|
var PluginAbstract = function PluginAbstract() {};
|
|
1635
|
-
PluginAbstract.dependencies =
|
|
1647
|
+
PluginAbstract.dependencies = [];
|
|
1636
1648
|
|
|
1637
1649
|
var state = function state(colorkeys) {
|
|
1638
1650
|
return plugin(function (pluginArgs) {
|
|
@@ -1718,6 +1730,218 @@ var themer = function themer(colors, darkMode) {
|
|
|
1718
1730
|
return require('tailwindcss-themer')(options);
|
|
1719
1731
|
};
|
|
1720
1732
|
|
|
1733
|
+
var FontFamily;
|
|
1734
|
+
(function (FontFamily) {
|
|
1735
|
+
FontFamily["Expressive"] = "expressive";
|
|
1736
|
+
FontFamily["Neutral"] = "neutral";
|
|
1737
|
+
})(FontFamily || (FontFamily = {}));
|
|
1738
|
+
var FontPlugin = /*#__PURE__*/function (_PluginAbstract) {
|
|
1739
|
+
function FontPlugin(appService, options) {
|
|
1740
|
+
var _options$fontFamily$e, _options$fontFamily, _options$fontFamily$n, _options$fontFamily2;
|
|
1741
|
+
var _this;
|
|
1742
|
+
_this = _PluginAbstract.call(this) || this;
|
|
1743
|
+
_this.appService = void 0;
|
|
1744
|
+
_this.options = void 0;
|
|
1745
|
+
_this.fontFamily = void 0;
|
|
1746
|
+
_this.fontStyles = void 0;
|
|
1747
|
+
_this.appService = appService;
|
|
1748
|
+
_this.options = options;
|
|
1749
|
+
_this.fontFamily = {
|
|
1750
|
+
expressive: (_options$fontFamily$e = options == null || (_options$fontFamily = options.fontFamily) == null ? void 0 : _options$fontFamily.expressive) != null ? _options$fontFamily$e : ['Roboto', 'sans-serif'],
|
|
1751
|
+
neutral: (_options$fontFamily$n = options == null || (_options$fontFamily2 = options.fontFamily) == null ? void 0 : _options$fontFamily2.neutral) != null ? _options$fontFamily$n : ['Roboto', 'sans-serif']
|
|
1752
|
+
};
|
|
1753
|
+
_this.fontStyles = {
|
|
1754
|
+
display: {
|
|
1755
|
+
large: {
|
|
1756
|
+
fontWeight: 400,
|
|
1757
|
+
fontSize: 3.5625,
|
|
1758
|
+
lineHeight: 4,
|
|
1759
|
+
letterSpacing: -0.015625,
|
|
1760
|
+
fontFamily: FontFamily.Expressive
|
|
1761
|
+
},
|
|
1762
|
+
medium: {
|
|
1763
|
+
fontWeight: 400,
|
|
1764
|
+
fontSize: 2.8125,
|
|
1765
|
+
lineHeight: 3.25,
|
|
1766
|
+
fontFamily: FontFamily.Expressive
|
|
1767
|
+
},
|
|
1768
|
+
small: {
|
|
1769
|
+
fontWeight: 400,
|
|
1770
|
+
fontSize: 2.25,
|
|
1771
|
+
lineHeight: 2.75,
|
|
1772
|
+
fontFamily: FontFamily.Expressive
|
|
1773
|
+
}
|
|
1774
|
+
},
|
|
1775
|
+
headline: {
|
|
1776
|
+
large: {
|
|
1777
|
+
fontWeight: 400,
|
|
1778
|
+
fontSize: 2,
|
|
1779
|
+
lineHeight: 2.5,
|
|
1780
|
+
fontFamily: FontFamily.Expressive
|
|
1781
|
+
},
|
|
1782
|
+
medium: {
|
|
1783
|
+
fontWeight: 400,
|
|
1784
|
+
fontSize: 1.75,
|
|
1785
|
+
lineHeight: 2.25,
|
|
1786
|
+
fontFamily: FontFamily.Expressive
|
|
1787
|
+
},
|
|
1788
|
+
small: {
|
|
1789
|
+
fontWeight: 400,
|
|
1790
|
+
fontSize: 1.5,
|
|
1791
|
+
lineHeight: 2,
|
|
1792
|
+
fontFamily: FontFamily.Expressive
|
|
1793
|
+
}
|
|
1794
|
+
},
|
|
1795
|
+
title: {
|
|
1796
|
+
large: {
|
|
1797
|
+
fontWeight: 400,
|
|
1798
|
+
fontSize: 1.375,
|
|
1799
|
+
lineHeight: 1.75,
|
|
1800
|
+
fontFamily: FontFamily.Neutral
|
|
1801
|
+
},
|
|
1802
|
+
medium: {
|
|
1803
|
+
fontWeight: 500,
|
|
1804
|
+
fontSize: 1,
|
|
1805
|
+
lineHeight: 1.5,
|
|
1806
|
+
fontFamily: FontFamily.Neutral,
|
|
1807
|
+
letterSpacing: 0.009375
|
|
1808
|
+
},
|
|
1809
|
+
small: {
|
|
1810
|
+
fontWeight: 500,
|
|
1811
|
+
fontSize: 0.875,
|
|
1812
|
+
lineHeight: 1.25,
|
|
1813
|
+
fontFamily: FontFamily.Neutral,
|
|
1814
|
+
letterSpacing: 0.00625
|
|
1815
|
+
}
|
|
1816
|
+
},
|
|
1817
|
+
label: {
|
|
1818
|
+
large: {
|
|
1819
|
+
fontWeight: 500,
|
|
1820
|
+
fontSize: 0.875,
|
|
1821
|
+
lineHeight: 1.25,
|
|
1822
|
+
fontFamily: FontFamily.Neutral,
|
|
1823
|
+
letterSpacing: 0.00625
|
|
1824
|
+
},
|
|
1825
|
+
medium: {
|
|
1826
|
+
fontWeight: 500,
|
|
1827
|
+
fontSize: 0.75,
|
|
1828
|
+
lineHeight: 1,
|
|
1829
|
+
fontFamily: FontFamily.Neutral,
|
|
1830
|
+
letterSpacing: 0.03125
|
|
1831
|
+
},
|
|
1832
|
+
small: {
|
|
1833
|
+
fontWeight: 500,
|
|
1834
|
+
fontSize: 0.6875,
|
|
1835
|
+
lineHeight: 1,
|
|
1836
|
+
fontFamily: FontFamily.Neutral,
|
|
1837
|
+
letterSpacing: 0.03125
|
|
1838
|
+
}
|
|
1839
|
+
},
|
|
1840
|
+
body: {
|
|
1841
|
+
large: {
|
|
1842
|
+
fontWeight: 400,
|
|
1843
|
+
fontSize: 1,
|
|
1844
|
+
lineHeight: 1.5625,
|
|
1845
|
+
fontFamily: FontFamily.Neutral,
|
|
1846
|
+
letterSpacing: 0.03125
|
|
1847
|
+
},
|
|
1848
|
+
medium: {
|
|
1849
|
+
fontWeight: 400,
|
|
1850
|
+
fontSize: 0.875,
|
|
1851
|
+
lineHeight: 1.25,
|
|
1852
|
+
fontFamily: FontFamily.Neutral,
|
|
1853
|
+
letterSpacing: 0.015625
|
|
1854
|
+
},
|
|
1855
|
+
small: {
|
|
1856
|
+
fontWeight: 400,
|
|
1857
|
+
fontSize: 0.75,
|
|
1858
|
+
lineHeight: 1,
|
|
1859
|
+
fontFamily: FontFamily.Neutral,
|
|
1860
|
+
letterSpacing: 0.025
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
};
|
|
1864
|
+
if (options && options.fontStyles) Object.entries(options.fontStyles).forEach(function (_ref) {
|
|
1865
|
+
var key = _ref[0],
|
|
1866
|
+
fontParam = _ref[1];
|
|
1867
|
+
var fontRole = key;
|
|
1868
|
+
Object.entries(fontParam).forEach(function (_ref2) {
|
|
1869
|
+
var size = _ref2[0],
|
|
1870
|
+
fontStyle = _ref2[1];
|
|
1871
|
+
var fontSize = size;
|
|
1872
|
+
if (fontStyle) {
|
|
1873
|
+
_this.fontStyles[fontRole][fontSize] = _extends({}, _this.fontStyles[fontRole][fontSize], fontStyle);
|
|
1874
|
+
}
|
|
1875
|
+
});
|
|
1876
|
+
});
|
|
1877
|
+
return _this;
|
|
1878
|
+
}
|
|
1879
|
+
_inheritsLoose(FontPlugin, _PluginAbstract);
|
|
1880
|
+
FontPlugin.config = function config(options) {
|
|
1881
|
+
return options;
|
|
1882
|
+
};
|
|
1883
|
+
var _proto = FontPlugin.prototype;
|
|
1884
|
+
_proto.getFonts = function getFonts() {
|
|
1885
|
+
return {
|
|
1886
|
+
fontStyles: this.fontStyles,
|
|
1887
|
+
fontFamily: this.fontFamily
|
|
1888
|
+
};
|
|
1889
|
+
};
|
|
1890
|
+
return FontPlugin;
|
|
1891
|
+
}(PluginAbstract);
|
|
1892
|
+
|
|
1893
|
+
var font = function font(fontStyles, responsiveBreakPoints) {
|
|
1894
|
+
var createUtilities = function createUtilities(_ref) {
|
|
1895
|
+
var theme = _ref.theme;
|
|
1896
|
+
var pixelUnit = 'rem';
|
|
1897
|
+
var newUtilities = {};
|
|
1898
|
+
var baseTextStyle = function baseTextStyle(sizeValue) {
|
|
1899
|
+
return {
|
|
1900
|
+
fontSize: sizeValue.fontSize + pixelUnit,
|
|
1901
|
+
fontWeight: sizeValue.fontWeight,
|
|
1902
|
+
lineHeight: sizeValue.lineHeight + pixelUnit,
|
|
1903
|
+
letterSpacing: sizeValue.letterSpacing ? sizeValue.letterSpacing + pixelUnit : null,
|
|
1904
|
+
fontFamily: theme('fontFamily.' + sizeValue.fontFamily)
|
|
1905
|
+
};
|
|
1906
|
+
};
|
|
1907
|
+
var responsiveTextStyle = function responsiveTextStyle(sizeValue, breakPointName, breakPointRatio) {
|
|
1908
|
+
var _ref2;
|
|
1909
|
+
return _ref2 = {}, _ref2["@media (min-width: " + theme('screens.' + breakPointName, {}) + ")"] = {
|
|
1910
|
+
fontSize: sizeValue.fontSize * breakPointRatio + pixelUnit,
|
|
1911
|
+
lineHeight: sizeValue.lineHeight * breakPointRatio + pixelUnit
|
|
1912
|
+
}, _ref2;
|
|
1913
|
+
};
|
|
1914
|
+
for (var _i = 0, _Object$entries = Object.entries(fontStyles); _i < _Object$entries.length; _i++) {
|
|
1915
|
+
var _Object$entries$_i = _Object$entries[_i],
|
|
1916
|
+
roleName = _Object$entries$_i[0],
|
|
1917
|
+
roleValue = _Object$entries$_i[1];
|
|
1918
|
+
var _loop = function _loop() {
|
|
1919
|
+
var _Object$entries2$_i = _Object$entries2[_i2],
|
|
1920
|
+
sizeName = _Object$entries2$_i[0],
|
|
1921
|
+
sizeValue = _Object$entries2$_i[1];
|
|
1922
|
+
newUtilities['.text-' + roleName + '-' + sizeName] = _extends({}, baseTextStyle(sizeValue), Object.entries(responsiveBreakPoints).reduce(function (acc, _ref3) {
|
|
1923
|
+
var breakPointName = _ref3[0],
|
|
1924
|
+
breakPointRatio = _ref3[1];
|
|
1925
|
+
acc = _extends({}, acc, responsiveTextStyle(sizeValue, breakPointName, breakPointRatio));
|
|
1926
|
+
return acc;
|
|
1927
|
+
}, {}));
|
|
1928
|
+
};
|
|
1929
|
+
for (var _i2 = 0, _Object$entries2 = Object.entries(roleValue); _i2 < _Object$entries2.length; _i2++) {
|
|
1930
|
+
_loop();
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
return newUtilities;
|
|
1934
|
+
};
|
|
1935
|
+
return plugin(function (_ref4) {
|
|
1936
|
+
var addUtilities = _ref4.addUtilities,
|
|
1937
|
+
theme = _ref4.theme;
|
|
1938
|
+
var newUtilities = createUtilities({
|
|
1939
|
+
theme: theme
|
|
1940
|
+
});
|
|
1941
|
+
addUtilities(newUtilities);
|
|
1942
|
+
});
|
|
1943
|
+
};
|
|
1944
|
+
|
|
1721
1945
|
var TailwindPlugin = /*#__PURE__*/function (_PluginAbstract) {
|
|
1722
1946
|
function TailwindPlugin(appService, options) {
|
|
1723
1947
|
var _this;
|
|
@@ -1753,18 +1977,18 @@ var TailwindPlugin = /*#__PURE__*/function (_PluginAbstract) {
|
|
|
1753
1977
|
colors[newKey][isDark ? 'dark' : 'light'] = value.getHex();
|
|
1754
1978
|
}
|
|
1755
1979
|
}
|
|
1756
|
-
|
|
1980
|
+
var _this$appService$plug = this.appService.pluginService.getPlugin(FontPlugin).getFonts(),
|
|
1981
|
+
fontStyles = _this$appService$plug.fontStyles,
|
|
1982
|
+
fontFamily = _this$appService$plug.fontFamily;
|
|
1757
1983
|
return {
|
|
1758
1984
|
colors: {},
|
|
1759
|
-
fontFamily:
|
|
1760
|
-
|
|
1761
|
-
neutral: []
|
|
1762
|
-
},
|
|
1763
|
-
plugins: [state(Object.keys(colors)), themer(colors, this.options.darkMode)]
|
|
1985
|
+
fontFamily: fontFamily,
|
|
1986
|
+
plugins: [state(Object.keys(colors)), themer(colors, this.options.darkMode), font(fontStyles, this.options.responsiveBreakPoints)]
|
|
1764
1987
|
};
|
|
1765
1988
|
};
|
|
1766
1989
|
return TailwindPlugin;
|
|
1767
1990
|
}(PluginAbstract);
|
|
1991
|
+
TailwindPlugin.dependencies = [FontPlugin];
|
|
1768
1992
|
|
|
1769
1993
|
var createTheme = function createTheme() {
|
|
1770
1994
|
var app = bootstrapFromConfig();
|