forked from sqlpage/SQLPage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path13_tab.sql
121 lines (114 loc) · 4.16 KB
/
13_tab.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
INSERT INTO component (name, description, icon, introduced_in_version)
VALUES (
'tab',
'Build a tabbed interface, with each tab being a link to a page. Each tab can be in two states: active or inactive.',
'row-insert-bottom',
'0.9.5'
);
INSERT INTO parameter (
component,
name,
description,
type,
top_level,
optional
)
VALUES (
'tab',
'title',
'Text to display on the tab. If link is not set, the link will be the current page with a ''$tab'' parameter set to the tab''s title. If ''id'' is set, the page will be scrolled to the tab.',
'TEXT',
FALSE,
FALSE
),
(
'tab',
'link',
'Link to the page to display when the tab is clicked. By default, the link refers to the current page, with a ''tab'' parameter set to the tab''s title and hash set to the id (if passed) - this brings us back to the location of the tab after submission.',
'TEXT',
FALSE,
TRUE
),
(
'tab',
'active',
'Whether the tab is active or not. Defaults to false.',
'BOOLEAN',
FALSE,
TRUE
),
(
'tab',
'icon',
'Name of the icon to display on the tab. See tabler-icons.io for a list of available icons.',
'TEXT',
FALSE,
TRUE
),
(
'tab',
'color',
'Color of the tab. See preview.tabler.io/colors.html for a list of available colors.',
'TEXT',
FALSE,
TRUE
),
(
'tab',
'description',
'Description of the tab. This is displayed when the user hovers over the tab.',
'TEXT',
FALSE,
TRUE
),
(
'tab',
'center',
'Whether the tabs should be centered or not. Defaults to false.',
'BOOLEAN',
TRUE,
TRUE
)
;
INSERT INTO example (component, description, properties)
VALUES (
'tab',
'This example shows a very basic set of three tabs. The first tab is active. You could use this at the top of a page for easy navigation.
To implement contents that change based on the active tab, use the `tab` parameter in the page query string.
For example, if the page is `/my-page.sql`, then the first tab will have a link of `/my-page.sql?tab=My+First+tab`.
You could then for instance display contents coming from the database based on the value of the `tab` parameter.
For instance: `SELECT ''text'' AS component, contents_md FROM my_page_contents WHERE tab = $tab`.
Or you could write different queries for different tabs and use the `$tab` parameter with a static value in a where clause to switch between tabs:
```sql
select ''tab'' as component;
select ''Projects'' as title, $tab = ''Projects'' as active;
select ''Tasks'' as title, $tab = ''Tasks'' as active;
select ''table'' as component;
select * from my_projects where $tab = ''Projects'';
select * from my_tasks where $tab = ''Tasks'';
```
Note that the example below is completely static, and does not use the `tab` parameter to actually switch between tabs.
View the [dynamic tabs example](/examples/tabs/).
',
JSON(
'[
{ "component": "tab" },
{ "title": "This tab does not exist", "active": true, "link": "?component=tab&tab=tab_1" },
{ "title": "I am not a true tab", "link": "?component=tab&tab=tab_2" },
{ "title": "Do not click here", "link": "?component=tab&tab=tab_3" }
]'
)
),
(
'tab',
'This example shows a more sophisticated set of tabs. The tabs are centered, the active tab has a different color, and all the tabs have a custom link and icon.',
JSON(
'[
{ "component": "tab", "center": true },
{ "title": "Hero", "link": "?component=hero#component", "icon": "home", "description": "The hero component is a full-width banner with a title and an image." },
{ "title": "Tab", "link": "?component=tab#component", "icon": "user", "color": "purple" },
{ "title": "Card", "link": "?component=card#component", "icon": "credit-card" }
]'
)
)
;