tgui-core 1.6.1 → 1.7.1

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/README.md CHANGED
@@ -41,7 +41,7 @@ You have two options for importing styles:
41
41
  To import all styles at once, add the following line to your main Sass file:
42
42
 
43
43
  ```scss
44
- @use "pkg:tgui-core/styles";
44
+ @use "~tgui-core/styles";
45
45
  ```
46
46
 
47
47
  ### 2. Importing Individual Styles
@@ -49,9 +49,9 @@ To import all styles at once, add the following line to your main Sass file:
49
49
  To import individual styles, add any of the exported styles to your main Sass file:
50
50
 
51
51
  ```scss
52
- @use "pkg:tgui-core/styles/components/Button";
53
- @use "pkg:tgui-core/styles/components/Dialog";
54
- @use "pkg:tgui-core/styles/components/NoticeBox";
52
+ @use "~tgui-core/styles/components/Button";
53
+ @use "~tgui-core/styles/components/Dialog";
54
+ @use "~tgui-core/styles/components/NoticeBox";
55
55
  ```
56
56
 
57
57
  ## License
package/package.json CHANGED
@@ -1,24 +1,24 @@
1
1
  {
2
2
  "name": "tgui-core",
3
- "version": "1.6.1",
3
+ "version": "1.7.1",
4
4
  "description": "TGUI core component library",
5
5
  "keywords": ["TGUI", "library", "typescript"],
6
- "files": ["dist"],
6
+ "files": ["dist", "styles"],
7
7
  "exports": {
8
8
  "./components": {
9
9
  "import": "./dist/components/index.js",
10
10
  "require": "./dist/components/index.cjs"
11
11
  },
12
- "./*": {
13
- "import": "./dist/common/*.js",
14
- "require": "./dist/common/*.cjs"
15
- },
16
12
  "./styles": {
17
- "default": "./lib/styles/main.scss",
18
- "sass": "./lib/styles/main.scss"
13
+ "default": "./styles/main.scss",
14
+ "sass": "./styles/main.scss"
19
15
  },
20
16
  "./styles/components/*": {
21
- "sass": "./lib/styles/components/*.scss"
17
+ "sass": "./styles/components/*"
18
+ },
19
+ "./*": {
20
+ "import": "./dist/common/*.js",
21
+ "require": "./dist/common/*.cjs"
22
22
  }
23
23
  },
24
24
  "repository": {
@@ -0,0 +1,27 @@
1
+ @use "sass:color";
2
+ @use "sass:math";
3
+
4
+ $color-fg: hsl(0, 0%, 100%) !default;
5
+ $color-bg: hsl(0, 0%, 14%) !default;
6
+ $color-bg-section: rgba(0, 0, 0, 0.33) !default;
7
+ $color-bg-grad-spread: 2% !default;
8
+ $color-bg-start: color.adjust(
9
+ $color-bg,
10
+ $lightness: $color-bg-grad-spread
11
+ ) !default;
12
+ $color-bg-end: color.adjust(
13
+ $color-bg,
14
+ $lightness: -$color-bg-grad-spread
15
+ ) !default;
16
+
17
+ $unit: 12px;
18
+ $font-size: 1 * $unit !default;
19
+ $border-radius: 0.16em !default;
20
+
21
+ @function em($px) {
22
+ @return 1em * math.div($px, $unit);
23
+ }
24
+
25
+ @function rem($px) {
26
+ @return 1rem * math.div($px, $unit);
27
+ }
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Copyright (c) 2020 Aleksej Komarov
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ @use "sass:color";
7
+ @use "sass:map";
8
+ @use "sass:meta";
9
+
10
+ // Base colors
11
+ $black: hsl(0, 0%, 0%) !default;
12
+ $white: hsl(0, 0%, 100%) !default;
13
+ $red: hsl(0, 72%, 50%) !default;
14
+ $orange: hsl(24, 89%, 54%) !default;
15
+ $yellow: hsl(52, 97%, 52%) !default;
16
+ $olive: hsl(68, 76%, 45%) !default;
17
+ $green: hsl(136, 70%, 41%) !default;
18
+ $teal: hsl(178, 100%, 35%) !default;
19
+ $blue: hsl(208, 65%, 47%) !default;
20
+ $violet: hsl(259, 60%, 50%) !default;
21
+ $purple: hsl(288, 60%, 49%) !default;
22
+ $pink: hsl(326, 71%, 56%) !default;
23
+ $brown: hsl(24, 47%, 45%) !default;
24
+ $grey: hsl(0, 0%, 47%) !default;
25
+ $light-grey: hsl(0, 0%, 67%) !default;
26
+
27
+ $primary: hsl(210, 37%, 46%) !default;
28
+ $good: hsl(94, 63%, 41%) !default;
29
+ $average: hsl(33, 89%, 50%) !default;
30
+ $bad: hsl(0, 72%, 50%) !default;
31
+ $label: hsl(210, 18%, 58%) !default;
32
+
33
+ // Background and foreground color lightness ratios
34
+ $bg-lightness: -15% !default;
35
+ $fg-lightness: 10% !default;
36
+
37
+ @function bg($color) {
38
+ @return color.scale($color, $lightness: $bg-lightness);
39
+ }
40
+
41
+ @function fg($color) {
42
+ @return color.scale($color, $lightness: $fg-lightness);
43
+ }
44
+
45
+ // Mappings of color names
46
+
47
+ $_gen_map: (
48
+ "black": $black,
49
+ "white": $white,
50
+ "red": $red,
51
+ "orange": $orange,
52
+ "yellow": $yellow,
53
+ "olive": $olive,
54
+ "green": $green,
55
+ "teal": $teal,
56
+ "blue": $blue,
57
+ "violet": $violet,
58
+ "purple": $purple,
59
+ "pink": $pink,
60
+ "brown": $brown,
61
+ "grey": $grey,
62
+ "light-grey": $light-grey,
63
+ "good": $good,
64
+ "average": $average,
65
+ "bad": $bad,
66
+ "label": $label,
67
+ );
68
+
69
+ // Foreground color names for which to generate a color map
70
+ $fg-map-keys: map.keys($_gen_map) !default;
71
+ // Background color names for which to generate a color map
72
+ $bg-map-keys: map.keys($_gen_map) !default;
73
+
74
+ $fg-map: ();
75
+ @each $color-name in $fg-map-keys {
76
+ // prettier-ignore
77
+ $fg-map: map.merge($fg-map, (
78
+ $color-name: fg(map.get($_gen_map, $color-name)),
79
+ ));
80
+ }
81
+
82
+ $bg-map: ();
83
+ @each $color-name in $bg-map-keys {
84
+ // prettier-ignore
85
+ $bg-map: map.merge($bg-map, (
86
+ $color-name: bg(map.get($_gen_map, $color-name)),
87
+ ));
88
+ }
@@ -0,0 +1,15 @@
1
+ @use "../base";
2
+ @use "../colors";
3
+
4
+ $color-default: colors.fg(colors.$label) !default;
5
+
6
+ .BlockQuote {
7
+ color: $color-default;
8
+ border-left: base.em(2px) solid $color-default;
9
+ padding-left: 0.5em;
10
+ margin-bottom: 0.5em;
11
+
12
+ &:last-child {
13
+ margin-bottom: 0;
14
+ }
15
+ }
@@ -0,0 +1,171 @@
1
+ @use "../base";
2
+ @use "../colors";
3
+ @use "../functions" as *;
4
+
5
+ $color-default: colors.bg(colors.$primary) !default;
6
+ $color-disabled: hsl(0, 0%, 60%) !default;
7
+ $color-selected: colors.bg(colors.$green) !default;
8
+ $color-caution: colors.bg(colors.$yellow) !default;
9
+ $color-danger: colors.bg(colors.$red) !default;
10
+ $color-transparent-text: rgba(255, 255, 255, 0.5) !default;
11
+ $border-radius: base.$border-radius !default;
12
+ $bg-map: colors.$bg-map !default;
13
+
14
+ @mixin button-color($color) {
15
+ // Adapt text color to background luminance to ensure high contast
16
+ $luminance: luminance($color);
17
+ $text-color: if($luminance > 0.4, rgba(0, 0, 0, 1), rgba(255, 255, 255, 1));
18
+
19
+ transition:
20
+ color 50ms,
21
+ background-color 50ms;
22
+ background-color: $color;
23
+ color: $text-color;
24
+
25
+ &:focus {
26
+ transition:
27
+ color 100ms,
28
+ background-color 100ms;
29
+ }
30
+
31
+ &:hover {
32
+ background-color: lighten($color, 30%);
33
+ color: $text-color;
34
+ }
35
+ }
36
+
37
+ .Button {
38
+ position: relative;
39
+ display: inline-block;
40
+ line-height: 1.667em;
41
+ padding: 0 0.5em;
42
+ margin-right: base.em(2px);
43
+ white-space: nowrap;
44
+ outline: 0;
45
+ border-radius: $border-radius;
46
+ margin-bottom: base.em(2px);
47
+ // Disable selection in buttons
48
+ user-select: none;
49
+ -ms-user-select: none;
50
+
51
+ &:last-child {
52
+ margin-right: 0;
53
+ margin-bottom: 0;
54
+ }
55
+
56
+ .fa,
57
+ .fas,
58
+ .far {
59
+ margin-left: -0.25em;
60
+ margin-right: -0.25em;
61
+ min-width: 1.333em;
62
+ text-align: center;
63
+ }
64
+ }
65
+
66
+ .Button--dropdown {
67
+ line-height: base.em(16px);
68
+ height: base.em(22px);
69
+ padding: 0.2rem 0.5rem;
70
+ }
71
+
72
+ .Button--hasContent {
73
+ // Add a margin to the icon to keep it separate from the text
74
+ .fa,
75
+ .fas,
76
+ .far {
77
+ margin-right: 0.25em;
78
+ }
79
+ }
80
+
81
+ .Button--hasContent.Button--iconPosition--right {
82
+ .fa,
83
+ .fas,
84
+ .far {
85
+ margin-right: 0px;
86
+ margin-left: 3px;
87
+ }
88
+ }
89
+
90
+ .Button--ellipsis {
91
+ display: block;
92
+ text-overflow: ellipsis;
93
+ overflow: hidden;
94
+ }
95
+
96
+ .Button--fluid {
97
+ display: block;
98
+ margin-left: 0;
99
+ margin-right: 0;
100
+ }
101
+
102
+ .Button--circular {
103
+ border-radius: 50%;
104
+ }
105
+
106
+ .Button--compact {
107
+ padding: 0 0.25em;
108
+ line-height: 1.333em;
109
+ }
110
+
111
+ @each $color-name, $color-value in $bg-map {
112
+ .Button--color--#{$color-name} {
113
+ @include button-color($color-value);
114
+ }
115
+ }
116
+
117
+ .Button--color--default {
118
+ @include button-color($color-default);
119
+ }
120
+
121
+ .Button--color--caution {
122
+ @include button-color($color-caution);
123
+ }
124
+
125
+ .Button--color--danger {
126
+ @include button-color($color-danger);
127
+ }
128
+
129
+ .Button--color--transparent {
130
+ @include button-color(base.$color-bg);
131
+ background-color: rgba(base.$color-bg, 0);
132
+ color: $color-transparent-text;
133
+ }
134
+
135
+ .Button--disabled {
136
+ background-color: $color-disabled !important;
137
+ }
138
+
139
+ .Button--selected {
140
+ @include button-color($color-selected);
141
+ }
142
+
143
+ .Button--flex {
144
+ display: inline-flex; //Inline even for fluid
145
+ flex-direction: column;
146
+ }
147
+
148
+ .Button--flex--fluid {
149
+ width: 100%;
150
+ }
151
+
152
+ .Button--verticalAlignContent--top {
153
+ justify-content: flex-start;
154
+ }
155
+
156
+ .Button--verticalAlignContent--middle {
157
+ justify-content: center;
158
+ }
159
+
160
+ .Button--verticalAlignContent--bottom {
161
+ justify-content: flex-end;
162
+ }
163
+
164
+ .Button__content {
165
+ display: block;
166
+ align-self: stretch;
167
+ }
168
+
169
+ .Button__textMargin {
170
+ margin-left: 0.4rem;
171
+ }
@@ -0,0 +1,7 @@
1
+ .ColorBox {
2
+ display: inline-block;
3
+ width: 1em;
4
+ height: 1em;
5
+ line-height: 1em;
6
+ text-align: center;
7
+ }
@@ -0,0 +1,105 @@
1
+ @use "../base";
2
+
3
+ $background-color: base.$color-bg !default;
4
+
5
+ .Dialog {
6
+ position: fixed;
7
+ left: 0;
8
+ top: 0;
9
+ right: 0;
10
+ bottom: 0;
11
+ background-color: rgba(0, 0, 0, 0.5);
12
+ display: flex;
13
+ align-items: center;
14
+ justify-content: center;
15
+ }
16
+
17
+ .Dialog__content {
18
+ background-color: $background-color;
19
+ font-family: Consolas, monospace;
20
+ font-size: base.em(14px);
21
+ display: flex;
22
+ flex-direction: column;
23
+ }
24
+
25
+ .Dialog__header {
26
+ display: flex;
27
+ height: 2em;
28
+ line-height: 1.928em;
29
+ background-color: rgba(0, 0, 0, 0.5);
30
+ user-select: none;
31
+ -ms-user-select: none;
32
+ }
33
+
34
+ .Dialog__title {
35
+ display: inline;
36
+ font-style: italic;
37
+ margin-left: 1rem;
38
+ margin-right: 2rem;
39
+ flex-grow: 1;
40
+ opacity: 0.33;
41
+ }
42
+
43
+ .Dialog__body {
44
+ margin: 2rem 1rem 2rem 1rem;
45
+ flex-grow: 1;
46
+ }
47
+
48
+ .Dialog__footer {
49
+ display: flex;
50
+ flex-direction: row;
51
+ justify-content: flex-end;
52
+ padding: 1rem;
53
+ background-color: rgba(0, 0, 0, 0.25);
54
+ }
55
+
56
+ .Dialog__button {
57
+ margin: 0 1rem 0 1rem;
58
+ height: 2rem;
59
+ min-width: 6rem;
60
+ text-align: center;
61
+ }
62
+
63
+ .SaveAsDialog__inputs {
64
+ display: flex;
65
+ flex-direction: row;
66
+ align-items: center;
67
+ padding-left: 3rem;
68
+ justify-content: flex-end;
69
+ margin-right: 1rem;
70
+ }
71
+
72
+ .SaveAsDialog__input {
73
+ margin-left: 1rem;
74
+ width: 80%;
75
+ }
76
+
77
+ .SaveAsDialog__label {
78
+ vertical-align: center;
79
+ }
80
+
81
+ .Dialog__FileList {
82
+ position: relative;
83
+ display: flex;
84
+ flex-wrap: wrap;
85
+ flex-grow: 1;
86
+ align-content: flex-start;
87
+ max-height: 20rem;
88
+ overflow: auto;
89
+ overflow-y: scroll;
90
+ }
91
+
92
+ .Dialog__FileEntry {
93
+ text-align: center;
94
+ margin: 1rem;
95
+ }
96
+
97
+ .Dialog__FileIcon {
98
+ display: inline-block;
99
+ margin: 0 0 1rem 0;
100
+ position: relative;
101
+ width: 6vh;
102
+ height: auto;
103
+ text-align: center;
104
+ cursor: default;
105
+ }
@@ -0,0 +1,18 @@
1
+ $background-dimness: 0.75 !default;
2
+
3
+ .Dimmer {
4
+ // Align everything in the middle.
5
+ // A fat middle finger for anything less than IE11.
6
+ display: flex;
7
+ justify-content: center;
8
+ align-items: center;
9
+ // Fill positioned parent
10
+ position: absolute;
11
+ top: 0;
12
+ bottom: 0;
13
+ left: 0;
14
+ right: 0;
15
+ // Dim everything around it
16
+ background-color: rgba(0, 0, 0, $background-dimness);
17
+ z-index: 1;
18
+ }
@@ -0,0 +1,22 @@
1
+ @use "../base";
2
+
3
+ $color: rgba(255, 255, 255, 0.1) !default;
4
+ $thickness: base.em(2px) !default;
5
+ $spacing: 0.5em;
6
+
7
+ .Divider--horizontal {
8
+ margin: $spacing 0;
9
+
10
+ &:not(.Divider--hidden) {
11
+ border-top: $thickness solid $color;
12
+ }
13
+ }
14
+
15
+ .Divider--vertical {
16
+ height: 100%;
17
+ margin: 0 $spacing;
18
+
19
+ &:not(.Divider--hidden) {
20
+ border-left: $thickness solid $color;
21
+ }
22
+ }
@@ -0,0 +1,67 @@
1
+ @use "../base";
2
+
3
+ .Dropdown {
4
+ display: flex;
5
+ align-items: flex-start;
6
+ }
7
+
8
+ .Dropdown__control {
9
+ flex: 1;
10
+ font-family: Verdana, sans-serif;
11
+ font-size: base.em(12px);
12
+ overflow: hidden;
13
+ user-select: none;
14
+ width: base.em(100px);
15
+ }
16
+
17
+ .Dropdown__arrow-button {
18
+ float: right;
19
+ padding-left: 0.35em;
20
+ width: 1.2em;
21
+ border-left: base.em(1px) solid rgba(0, 0, 0, 0.25);
22
+ }
23
+
24
+ .Dropdown__menu {
25
+ overflow-y: auto;
26
+ align-items: center;
27
+ max-height: base.em(200px);
28
+ border-radius: 0 0 base.em(2px) base.em(2px);
29
+ color: hsl(0, 0%, 100%);
30
+ background-color: hsl(0, 0%, 0%);
31
+ background-color: hsla(0, 0%, 0%, 0.75);
32
+ }
33
+
34
+ .Dropdown__menu-scroll {
35
+ overflow-y: scroll;
36
+ }
37
+
38
+ .Dropdown__menuentry {
39
+ padding: base.em(2px) base.em(4px);
40
+ font-family: Verdana, sans-serif;
41
+ font-size: base.em(12px);
42
+ line-height: base.em(17px);
43
+ transition: background-color 100ms ease-out;
44
+
45
+ &.selected {
46
+ background-color: rgba(255, 255, 255, 0.5) !important;
47
+ transition: background-color 0ms;
48
+ }
49
+
50
+ &:hover {
51
+ background-color: rgba(255, 255, 255, 0.2);
52
+ transition: background-color 0ms;
53
+ }
54
+ }
55
+
56
+ .Dropdown__over {
57
+ top: auto;
58
+ bottom: 100%;
59
+ }
60
+
61
+ .Dropdown__selected-text {
62
+ display: inline-block;
63
+ text-overflow: ellipsis;
64
+ white-space: nowrap;
65
+ height: base.em(17px);
66
+ width: calc(100% - 1.2em);
67
+ }
@@ -0,0 +1,26 @@
1
+ .Flex {
2
+ display: -ms-flexbox;
3
+ display: flex;
4
+ }
5
+
6
+ .Flex--inline {
7
+ display: inline-flex;
8
+ }
9
+
10
+ .Flex--iefix {
11
+ display: block;
12
+ }
13
+
14
+ .Flex--iefix.Flex--inline {
15
+ display: inline-block;
16
+ }
17
+
18
+ .Flex__item--iefix {
19
+ display: inline-block;
20
+ }
21
+
22
+ .Flex--iefix--column {
23
+ & > .Flex__item--iefix {
24
+ display: block;
25
+ }
26
+ }
@@ -0,0 +1,18 @@
1
+ .IconStack > .Icon {
2
+ position: absolute;
3
+ width: 100%;
4
+ text-align: center;
5
+ }
6
+
7
+ .IconStack {
8
+ position: relative;
9
+ display: inline-block;
10
+ height: 1.2em;
11
+ line-height: 2em;
12
+ vertical-align: middle;
13
+
14
+ &:after {
15
+ color: transparent;
16
+ content: ".";
17
+ }
18
+ }