Skip to content

Commit dbe40ab

Browse files
authoredSep 4, 2023
new settings
1 parent 4247acf commit dbe40ab

File tree

3 files changed

+123
-248
lines changed

3 files changed

+123
-248
lines changed
 

‎common/common.scss

Lines changed: 42 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -1,190 +1,89 @@
1-
// * Top section * //
1+
// * Import string splitter code * //
22

3-
@if $show_top_section_for_staff_only == "true" {
4-
.sidebar-section-wrapper.sidebar-section[data-section-name="community"] {
5-
display: none;
6-
}
7-
8-
.staff .sidebar-section-wrapper.sidebar-section[data-section-name="community"] {
9-
display: block;
10-
}
11-
}
3+
@import "str-to-list";
124

13-
@if $show_top_section_for_logged-in_only == "true" {
14-
.anon .sidebar-section-wrapper.sidebar-section[data-section-name="community"] {
15-
display: none;
16-
}
17-
}
185

19-
@if $hide_top_section_for_all == "true" {
20-
.sidebar-section-wrapper.sidebar-section[data-section-name="community"] {
21-
display: none;
22-
}
23-
}
24-
25-
26-
// * More drop down section * //
6+
// * Top section * //
277

28-
@if $show_more_for_staff_only == "true" {
29-
.btn-flat.sidebar-more-section-links-details-summary,
30-
.sidebar-more-section-links-details-summary.json-editor-btn-collapse {
31-
display: none;
32-
}
33-
.staff .btn-flat.sidebar-more-section-links-details-summary,
34-
.staff .sidebar-more-section-links-details-summary.json-editor-btn-collapse {
35-
display: flex;
36-
}
37-
}
388

39-
@if $show_more_for_logged-in_only == "true" {
40-
.anon .btn-flat.sidebar-more-section-links-details-summary,
41-
.anon .sidebar-more-section-links-details-summary.json-editor-btn-collapse {
42-
display: none;
43-
}
44-
}
9+
@if $show_these_sections_for_staff_only !="" {
4510

11+
$staff_sections: str-to-list("#{$show_these_sections_for_staff_only}", "|");
4612

47-
// * More drop-down sections * //
13+
@each $staff_section in $staff_sections {
4814

49-
@if $show_anniversaries_for_staff_only == "true" {
50-
.sidebar-section-link-wrapper {
51-
.sidebar-section-link {
52-
&[data-link-name="anniversaries"] {
53-
display: none;
54-
}
15+
.sidebar-section-wrapper.sidebar-section[data-section-name="#{$staff_section}"] {
16+
display: none;
5517
}
56-
}
5718

58-
.sidebar-section-link-wrapper {
59-
.staff .sidebar-section-link {
60-
&[data-link-name="anniversaries"] {
61-
display: block;
62-
}
19+
.staff .sidebar-section-wrapper.sidebar-section[data-section-name="#{$staff_section}"] {
20+
display: block;
6321
}
6422
}
6523
}
6624

67-
@if $show_birthdays_for_staff_only == "true" {
68-
.sidebar-section-link-wrapper {
69-
.sidebar-section-link {
70-
&[data-link-name="birthdays"] {
71-
display: none;
72-
}
73-
}
74-
}
25+
@if $show_these_sections_for_logged-in_only !="" {
7526

76-
.sidebar-section-link-wrapper {
77-
.staff .sidebar-section-link {
78-
&[data-link-name="birthdays"] {
79-
display: block;
80-
}
81-
}
82-
}
83-
}
27+
$user_sections: str-to-list("#{$show_these_sections_for_logged-in_only}", "|");
8428

29+
@each $user_section in $user_sections {
8530

86-
@if $show_docs_for_staff_only == "true" {
87-
.sidebar-section-link-wrapper {
88-
.sidebar-section-link {
89-
&[data-link-name="docs"] {
90-
display: none;
91-
}
31+
.sidebar-section-wrapper.sidebar-section[data-section-name="#{$user_section}"] {
32+
display: block;
9233
}
93-
}
9434

95-
.sidebar-section-link-wrapper {
96-
.staff .sidebar-section-link {
97-
&[data-link-name="docs"] {
98-
display: block;
99-
}
35+
.anon .sidebar-section-wrapper.sidebar-section[data-section-name="#{$user_section}"] {
36+
display: none;
10037
}
10138
}
10239
}
10340

104-
// * Categories and Tags sections * //
105-
106-
@if $show_categories_for_staff_only == "true" {
107-
.sidebar-section-wrapper.sidebar-section[data-section-name="categories"] {
108-
display: none;
109-
}
110-
111-
.staff .sidebar-section-wrapper.sidebar-section[data-section-name="categories"] {
112-
display: block;
113-
}
114-
}
115-
116-
@if $show_categories_for_logged-in_only == "true" {
117-
.anon .sidebar-section-wrapper.sidebar-section[data-section-name="categories"] {
118-
display: none;
119-
}
120-
}
41+
@if $show_these_links_for_staff_only !="" {
12142

122-
@if $show_tags_for_staff_only == "true" {
123-
.sidebar-section-wrapper.sidebar-section[data-section-name="tags"] {
124-
display: none;
125-
}
43+
$staff_links: str-to-list("#{$show_these_links_for_staff_only}", "|");
12644

127-
.staff .sidebar-section-wrapper.sidebar-section[data-section-name="tags"] {
128-
display: block;
129-
}
130-
}
45+
@each $staff_link in $staff_links {
13146

132-
@if $show_tags_for_logged-in_only == "true" {
133-
.anon .sidebar-section-wrapper.sidebar-section[data-section-name="tags"] {
134-
display: none;
135-
}
136-
}
137-
138-
// * Messages Section * //
139-
140-
@if $show_messages_for_staff_only == "true" {
141-
.sidebar-section-wrapper.sidebar-section[data-section-name="messages"] {
142-
display: none;
143-
}
47+
.sidebar-section-link-wrapper[data-list-item-name="#{$staff_link}"] {
48+
display: none;
49+
}
14450

145-
.staff .sidebar-section-wrapper.sidebar-section[data-section-name="messages"] {
146-
display: block;
51+
.staff .sidebar-section-link-wrapper[data-list-item-name="#{$staff_link}"] {
52+
display: block;
53+
}
14754
}
14855
}
14956

150-
@if $show_messages_for_logged-in_only == "true" {
151-
.anon .sidebar-section-wrapper.sidebar-section[data-section-name="messages"] {
152-
display: none;
153-
}
154-
}
57+
@if $show_these_links_for_logged-in_only !="" {
15558

156-
// * Channels Section *
59+
$user_links: str-to-list("#{$show_these_links_for_logged-in_only}", "|");
15760

158-
@if $show_channels_for_staff_only == "true" {
159-
.sidebar-section-wrapper.sidebar-section[data-section-name="chat-channels"] {
160-
display: none;
161-
}
61+
@each $user_link in $user_link {
16262

163-
.staff .sidebar-section-wrapper.sidebar-section[data-section-name="chat-channels"] {
164-
display: block;
165-
}
166-
}
63+
.sidebar-section-link-wrapper[data-list-item-name="#{$user_link}"] {
64+
display: block;
65+
}
16766

168-
@if $show_channels_for_logged-in_only == "true" {
169-
.anon .sidebar-section-wrapper.sidebar-section[data-section-name="chat-channels"] {
170-
display: none;
67+
.anon .sidebar-section-link-wrapper[data-list-item-name="#{$user_link}"] {
68+
display: none;
69+
}
17170
}
17271
}
17372

174-
// * Chat Section *
73+
// * More drop down section * //
17574

176-
@if $show_chat_for_staff_only == "true" {
177-
.sidebar-section-wrapper.sidebar-section[data-section-name="chat-dms"] {
75+
@if $show_more_for_staff_only =="true" {
76+
.btn-flat.sidebar-more-section-links-details-summary {
17877
display: none;
17978
}
18079

181-
.staff .sidebar-section-wrapper.sidebar-section[data-section-name="chat-dms"] {
182-
display: block;
80+
.staff .btn-flat.sidebar-more-section-links-details-summary {
81+
display: flex;
18382
}
18483
}
18584

186-
@if $show_chat_for_logged-in_only == "true" {
187-
.anon .sidebar-section-wrapper.sidebar-section[data-section-name="chat-dms"] {
85+
@if $show_more_for_logged-in_only =="true" {
86+
.anon .btn-flat.sidebar-more-section-links-details-summary {
18887
display: none;
18988
}
19089
}

‎scss/str-to-list.scss

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@function str-to-list($string, $separator, $startAt: 1) {
2+
$item: str-slice($string, $startAt);
3+
$list: ();
4+
$index: str-index($item, $separator);
5+
6+
@if $index ==null {
7+
$list: ($item);
8+
}
9+
10+
@else {
11+
$list: (str-slice($item, 1, $index - 1));
12+
$list: join($list, str-to-list($item, $separator, $startAt: $index + 1));
13+
}
14+
15+
@return $list;
16+
}

‎settings.yml

Lines changed: 65 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,91 @@
1-
show_top_section_for_staff_only:
2-
type: bool
3-
default: false
4-
description:
5-
en: "Show the top section of the navigation menu for staff only."
6-
7-
show_top_section_for_logged-in_only:
8-
type: bool
9-
default: false
10-
description:
11-
en: "Show the top section of the navigation menu for only logged-in users."
12-
13-
hide_top_section_for_all:
14-
type: bool
15-
default: false
16-
description:
17-
en: "Hide the top section of the navigation menu from all users."
1+
show_these_sections_for_staff_only:
2+
type: enum
3+
default: ""
4+
choices:
5+
- community
6+
- categories
7+
- tags
8+
- messages
9+
- chat-channels
10+
- chat-dms
11+
description:
12+
en: "Show these navigation sidebar sections for staff only."
13+
14+
show_these_sections_for_logged-in_only:
15+
type: enum
16+
default: ""
17+
choices:
18+
- community
19+
- categories
20+
- tags
21+
- messages
22+
- chat-channels
23+
- chat-dms
24+
description:
25+
en: "Show these navigation sidebar sections for logged-in only (hide from anon users)."
26+
27+
show_these_links_for_staff_only:
28+
type: enum
29+
default: ""
30+
choices:
31+
- everything
32+
- my-posts
33+
- anniversaries
34+
- birthdays
35+
- docs
36+
- badges
37+
- users
38+
- about
39+
description:
40+
en: "Show these navigation sidebar links for staff only."
41+
42+
show_these_links_for_logged-in_only:
43+
type: enum
44+
default: ""
45+
choices:
46+
- everything
47+
- my-posts
48+
- anniversaries
49+
- birthdays
50+
- docs
51+
- badges
52+
- users
53+
- about
54+
description:
55+
en: "Show these navigation sidebar links for logged-in users only (hide from anon users)."
1856

1957
show_more_for_staff_only:
2058
type: bool
2159
default: false
2260
description:
23-
en: "Show the more drop-down section of the navigation menu for staff only."
61+
en: "Show More drop-down section for staff only."
2462

2563
show_more_for_logged-in_only:
2664
type: bool
2765
default: false
2866
description:
29-
en: "Show the more section of the navigation menu for only logged-in users."
30-
31-
show_anniversaries_for_staff_only:
32-
type: bool
33-
default: false
34-
description:
35-
en: "Show the Anniversaries link in the More section for staff only, if you have the cakeday plugin installed. Only logged-in users can view by default."
36-
37-
show_birthdays_for_staff_only:
38-
type: bool
39-
default: false
40-
description:
41-
en: "Show the Birthdays link in the More section for staff only, if you have the cakeday plugin installed. Only logged-in users can view by default."
42-
43-
show_docs_for_staff_only:
44-
type: bool
45-
default: false
46-
description:
47-
en: "Show the Docs link in the More section for staff only, if you have the Docs plugin installed. Only logged-in users can view by default."
48-
49-
show_categories_for_staff_only:
50-
type: bool
51-
default: false
52-
description:
53-
en: "Show the Categories section for staff only."
54-
55-
show_categories_for_logged-in_only:
56-
type: bool
57-
default: false
58-
description:
59-
en: "Show the Categories section for logged-in users only."
60-
61-
show_tags_for_staff_only:
62-
type: bool
63-
default: false
64-
description:
65-
en: "Show the Tags section for staff only."
66-
67-
show_tags_for_logged-in_only:
68-
type: bool
69-
default: false
70-
description:
71-
en: "Show the Tags section for logged-in users only."
72-
73-
show_messages_for_staff_only:
74-
type: bool
75-
default: false
76-
description:
77-
en: "Show the Messages section for staff only."
78-
79-
show_messages_for_logged-in_only:
80-
type: bool
81-
default: false
82-
description:
83-
en: "Show the Messages section for logged-in users only."
84-
85-
show_channels_for_staff_only:
86-
type: bool
87-
default: false
88-
description:
89-
en: "Show the Channels section for staff only."
90-
91-
show_channels_for_logged-in_only:
92-
type: bool
93-
default: false
94-
description:
95-
en: "Show the Channels section for logged-in users only."
96-
97-
show_chat_for_staff_only:
98-
type: bool
99-
default: false
100-
description:
101-
en: "Show the Personal Chat section for staff only."
102-
103-
show_chat_for_logged-in_only:
104-
type: bool
105-
default: false
106-
description:
107-
en: "Show the Personal Chat section for logged-in users only."
67+
en: "Show More drop-down section for logged-in users only (hide from anon users)."
10868

10969
show_custom_for_staff_only:
11070
type: string
11171
default: "staff-menu"
11272
description:
113-
en: "Custom section to show for only for staff users. Use all lowercase and dashes for spaces (ie: Staff Menu = anon-menu)."
114-
115-
show_custom_for_anon_only:
116-
type: string
117-
default: "anon-menu"
118-
description:
119-
en: "Custom section to show for only for anonymous (not-logged-in) users. Use all lowercase and dashes for spaces (ie: Anon Menu = anon-menu)."
73+
en: "Custom section to show for only for staff users. Use all lowercase and dashes for spaces (ie: Staff Menu = staff-menu)."
12074

12175
show_custom_for_logged-in_only:
12276
type: string
12377
default: "user-menu"
12478
description:
12579
en: "Custom section to show for logged-in users only. Use all lowercase and dashes for spaces (ie: User Menu = user-menu)."
12680

81+
show_custom_for_anon_only:
82+
type: string
83+
default: "anon-menu"
84+
description:
85+
en: "Custom section to show for only for anonymous (not-logged-in) users. Use all lowercase and dashes for spaces (ie: Anon Menu = anon-menu)."
86+
12787
show_navigation_menu_to_logged-in_only:
12888
type: bool
12989
default: false
13090
description:
131-
en: "Show navigation menu for only logged-in users (hide the entire side-bar from anonymous users)."
91+
en: "Show entire navigation menu for only logged-in users (hide the entire side-bar from anon users)."

0 commit comments

Comments
 (0)
Please sign in to comment.