How to use Heading method in storybook-root

Best JavaScript code snippet using storybook-root

EditStructure.py

Source:EditStructure.py Github

copy

Full Screen

...35 cursor = vim.current.window.cursor[:]36 if not current_heading:37 # the user is in meta data region38 pos = cursor[0] - 139 heading = Heading(title=d.meta_information[pos], body=d.meta_information[pos + 1:])40 d.headings.insert(0, heading)41 del d.meta_information[pos:]42 d.write()43 vim.command((u'exe "normal %dgg"|startinsert!' % (heading.start_vim, )).encode(u'utf-8'))44 return heading45 heading = Heading(level=current_heading.level)46 # it's weird but this is the behavior of original orgmode47 if below is None:48 below = cursor[1] != 0 or end_of_last_child49 # insert newly created heading50 l = current_heading.get_parent_list()51 idx = current_heading.get_index_in_parent_list()52 if l is not None and idx is not None:53 l.insert(idx + (1 if below else 0), heading)54 else:55 raise HeadingDomError(u'Current heading is not properly linked in DOM')56 if below and not end_of_last_child:57 # append heading at the end of current heading and also take58 # over the children of current heading59 for child in current_heading.children:...

Full Screen

Full Screen

Navigator.py

Source:Navigator.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2import vim3from orgmode._vim import echo, ORGMODE, apply_count4from orgmode.menu import Submenu, ActionEntry5from orgmode.keybinding import Keybinding, MODE_VISUAL, MODE_OPERATOR, Plug6from orgmode.liborgmode.documents import Direction7class Navigator(object):8 u""" Implement navigation in org-mode documents """9 def __init__(self):10 object.__init__(self)11 self.menu = ORGMODE.orgmenu + Submenu(u'&Navigate Headings')12 self.keybindings = []13 @classmethod14 @apply_count15 def parent(cls, mode):16 u"""17 Focus parent heading18 :returns: parent heading or None19 """20 heading = ORGMODE.get_document().current_heading()21 if not heading:22 if mode == u'visual':23 vim.command(u'normal! gv'.encode(u'utf-8'))24 else:25 echo(u'No heading found')26 return27 if not heading.parent:28 if mode == u'visual':29 vim.command(u'normal! gv'.encode(u'utf-8'))30 else:31 echo(u'No parent heading found')32 return33 p = heading.parent34 if mode == u'visual':35 cls._change_visual_selection(heading, p, direction=Direction.BACKWARD, parent=True)36 else:37 vim.current.window.cursor = (p.start_vim, p.level + 1)38 return p39 @classmethod40 @apply_count41 def parent_next_sibling(cls, mode):42 u"""43 Focus the parent's next sibling44 :returns: parent's next sibling heading or None45 """46 heading = ORGMODE.get_document().current_heading()47 if not heading:48 if mode == u'visual':49 vim.command(u'normal! gv'.encode(u'utf-8'))50 else:51 echo(u'No heading found')52 return53 if not heading.parent or not heading.parent.next_sibling:54 if mode == u'visual':55 vim.command(u'normal! gv'.encode(u'utf-8'))56 else:57 echo(u'No parent heading found')58 return59 ns = heading.parent.next_sibling60 if mode == u'visual':61 cls._change_visual_selection(heading, ns, direction=Direction.FORWARD, parent=False)62 elif mode == u'operator':63 vim.current.window.cursor = (ns.start_vim, 0)64 else:65 vim.current.window.cursor = (ns.start_vim, ns.level + 1)66 return ns67 @classmethod68 def _change_visual_selection(cls, current_heading, heading, direction=Direction.FORWARD, noheadingfound=False, parent=False):69 current = vim.current.window.cursor[0]70 line_start, col_start = [ int(i) for i in vim.eval(u'getpos("\'<")'.encode(u'utf-8'))[1:3] ]71 line_end, col_end = [ int(i) for i in vim.eval(u'getpos("\'>")'.encode(u'utf-8'))[1:3] ]72 f_start = heading.start_vim73 f_end = heading.end_vim74 swap_cursor = True75 # << |visual start76 # selection end >>77 if current == line_start:78 if (direction == Direction.FORWARD and line_end < f_start) or noheadingfound and not direction == Direction.BACKWARD:79 swap_cursor = False80 # focus heading HERE81 # << |visual start82 # selection end >>83 # << |visual start84 # focus heading HERE85 # selection end >>86 if f_start < line_start and direction == Direction.BACKWARD:87 if current_heading.start_vim < line_start and not parent:88 line_start = current_heading.start_vim89 else:90 line_start = f_start91 elif (f_start < line_start or f_start < line_end) and not noheadingfound:92 line_start = f_start93 # << |visual start94 # selection end >>95 # focus heading HERE96 else:97 if direction == Direction.FORWARD:98 if line_end < f_start and not line_start == f_start - 1 and current_heading:99 # focus end of previous heading instead of beginning of next heading100 line_start = line_end101 line_end = f_start - 1102 else:103 # focus end of next heading104 line_start = line_end105 line_end = f_end106 elif direction == Direction.BACKWARD:107 if line_end < f_end:108 pass109 else:110 line_start = line_end111 line_end = f_end112 # << visual start113 # selection end| >>114 else:115 # focus heading HERE116 # << visual start117 # selection end| >>118 if line_start > f_start and line_end > f_end and not parent:119 line_end = f_end120 swap_cursor = False121 elif (line_start > f_start or \122 line_start == f_start) and line_end <= f_end and direction == Direction.BACKWARD:123 line_end = line_start124 line_start = f_start125 # << visual start126 # selection end and focus heading end HERE| >>127 # << visual start128 # focus heading HERE129 # selection end| >>130 # << visual start131 # selection end| >>132 # focus heading HERE133 else:134 if direction == Direction.FORWARD:135 if line_end < f_start - 1:136 # focus end of previous heading instead of beginning of next heading137 line_end = f_start - 1138 else:139 # focus end of next heading140 line_end = f_end141 else:142 line_end = f_end143 swap_cursor = False144 move_col_start = u'%dl' % (col_start - 1) if (col_start - 1) > 0 and (col_start - 1) < 2000000000 else u''145 move_col_end = u'%dl' % (col_end - 1) if (col_end - 1) > 0 and (col_end - 1) < 2000000000 else u''146 swap = u'o' if swap_cursor else u''147 vim.command((u'normal! %dgg%s%s%dgg%s%s' % \148 (line_start, move_col_start, vim.eval(u'visualmode()'.encode(u'utf-8')), line_end, move_col_end, swap)).encode(u'utf-8'))149 @classmethod150 def _focus_heading(cls, mode, direction=Direction.FORWARD, skip_children=False):151 u"""152 Focus next or previous heading in the given direction153 :direction: True for next heading, False for previous heading154 :returns: next heading or None155 """156 d = ORGMODE.get_document()157 current_heading = d.current_heading()158 heading = current_heading159 focus_heading = None160 # FIXME this is just a piece of really ugly and unmaintainable code. It161 # should be rewritten162 if not heading:163 if direction == Direction.FORWARD and d.headings \164 and vim.current.window.cursor[0] < d.headings[0].start_vim:165 # the cursor is in the meta information are, therefore focus166 # first heading167 focus_heading = d.headings[0]168 if not (heading or focus_heading):169 if mode == u'visual':170 # restore visual selection when no heading was found171 vim.command(u'normal! gv'.encode(u'utf-8'))172 else:173 echo(u'No heading found')174 return175 elif direction == Direction.BACKWARD:176 if vim.current.window.cursor[0] != heading.start_vim:177 # the cursor is in the body of the current heading, therefore178 # the current heading will be focused179 if mode == u'visual':180 line_start, col_start = [ int(i) for i in vim.eval(u'getpos("\'<")'.encode(u'utf-8'))[1:3] ]181 line_end, col_end = [ int(i) for i in vim.eval(u'getpos("\'>")'.encode(u'utf-8'))[1:3] ]182 if line_start >= heading.start_vim and line_end > heading.start_vim:183 focus_heading = heading184 else:185 focus_heading = heading186 # so far no heading has been found that the next focus should be on187 if not focus_heading:188 if not skip_children and direction == Direction.FORWARD and heading.children:189 focus_heading = heading.children[0]190 elif direction == Direction.FORWARD and heading.next_sibling:191 focus_heading = heading.next_sibling192 elif direction == Direction.BACKWARD and heading.previous_sibling:193 focus_heading = heading.previous_sibling194 if not skip_children:195 while focus_heading.children:196 focus_heading = focus_heading.children[-1]197 else:198 if direction == Direction.FORWARD:199 focus_heading = current_heading.next_heading200 else:201 focus_heading = current_heading.previous_heading202 noheadingfound = False203 if not focus_heading:204 if mode in (u'visual', u'operator'):205 # the cursor seems to be on the last or first heading of this206 # document and performes another next/previous operation207 focus_heading = heading208 noheadingfound = True209 else:210 if direction == Direction.FORWARD:211 echo(u'Already focussing last heading')212 else:213 echo(u'Already focussing first heading')214 return215 if mode == u'visual':216 cls._change_visual_selection(current_heading, focus_heading, direction=direction, noheadingfound=noheadingfound)217 elif mode == u'operator':218 if direction == Direction.FORWARD and vim.current.window.cursor[0] >= focus_heading.start_vim:219 vim.current.window.cursor = (focus_heading.end_vim, len(vim.current.buffer[focus_heading.end].decode(u'utf-8')))220 else:221 vim.current.window.cursor = (focus_heading.start_vim, 0)222 else:223 vim.current.window.cursor = (focus_heading.start_vim, focus_heading.level + 1)224 if noheadingfound:225 return226 return focus_heading227 @classmethod228 @apply_count229 def previous(cls, mode, skip_children=False):230 u"""231 Focus previous heading232 """233 return cls._focus_heading(mode, direction=Direction.BACKWARD, skip_children=skip_children)234 @classmethod235 @apply_count236 def next(cls, mode, skip_children=False):237 u"""238 Focus next heading239 """240 return cls._focus_heading(mode, direction=Direction.FORWARD, skip_children=skip_children)241 def register(self):242 # normal mode243 self.keybindings.append(Keybinding(u'g{', Plug('OrgJumpToParentNormal', u':py ORGMODE.plugins[u"Navigator"].parent(mode=u"normal")<CR>')))244 self.menu + ActionEntry(u'&Up', self.keybindings[-1])245 self.keybindings.append(Keybinding(u'g}', Plug('OrgJumpToParentsSiblingNormal', u':py ORGMODE.plugins[u"Navigator"].parent_next_sibling(mode=u"normal")<CR>')))246 self.menu + ActionEntry(u'&Down', self.keybindings[-1])247 self.keybindings.append(Keybinding(u'{', Plug(u'OrgJumpToPreviousNormal', u':py ORGMODE.plugins[u"Navigator"].previous(mode=u"normal")<CR>')))248 self.menu + ActionEntry(u'&Previous', self.keybindings[-1])249 self.keybindings.append(Keybinding(u'}', Plug(u'OrgJumpToNextNormal', u':py ORGMODE.plugins[u"Navigator"].next(mode=u"normal")<CR>')))250 self.menu + ActionEntry(u'&Next', self.keybindings[-1])251 # visual mode252 self.keybindings.append(Keybinding(u'g{', Plug(u'OrgJumpToParentVisual', u'<Esc>:<C-u>py ORGMODE.plugins[u"Navigator"].parent(mode=u"visual")<CR>', mode=MODE_VISUAL)))253 self.keybindings.append(Keybinding(u'g}', Plug('OrgJumpToParentsSiblingVisual', u'<Esc>:<C-u>py ORGMODE.plugins[u"Navigator"].parent_next_sibling(mode=u"visual")<CR>', mode=MODE_VISUAL)))254 self.keybindings.append(Keybinding(u'{', Plug(u'OrgJumpToPreviousVisual', u'<Esc>:<C-u>py ORGMODE.plugins[u"Navigator"].previous(mode=u"visual")<CR>', mode=MODE_VISUAL)))255 self.keybindings.append(Keybinding(u'}', Plug(u'OrgJumpToNextVisual', u'<Esc>:<C-u>py ORGMODE.plugins[u"Navigator"].next(mode=u"visual")<CR>', mode=MODE_VISUAL)))256 # operator-pending mode257 self.keybindings.append(Keybinding(u'g{', Plug(u'OrgJumpToParentOperator', u':<C-u>py ORGMODE.plugins[u"Navigator"].parent(mode=u"operator")<CR>', mode=MODE_OPERATOR)))258 self.keybindings.append(Keybinding(u'g}', Plug('OrgJumpToParentsSiblingOperator', u':<C-u>py ORGMODE.plugins[u"Navigator"].parent_next_sibling(mode=u"operator")<CR>', mode=MODE_OPERATOR)))259 self.keybindings.append(Keybinding(u'{', Plug(u'OrgJumpToPreviousOperator', u':<C-u>py ORGMODE.plugins[u"Navigator"].previous(mode=u"operator")<CR>', mode=MODE_OPERATOR)))260 self.keybindings.append(Keybinding(u'}', Plug(u'OrgJumpToNextOperator', u':<C-u>py ORGMODE.plugins[u"Navigator"].next(mode=u"operator")<CR>', mode=MODE_OPERATOR)))261 # section wise movement (skip children)262 # normal mode263 self.keybindings.append(Keybinding(u'[[', Plug(u'OrgJumpToPreviousSkipChildrenNormal', u':py ORGMODE.plugins[u"Navigator"].previous(mode=u"normal", skip_children=True)<CR>')))264 self.menu + ActionEntry(u'Ne&xt Same Level', self.keybindings[-1])265 self.keybindings.append(Keybinding(u']]', Plug(u'OrgJumpToNextSkipChildrenNormal', u':py ORGMODE.plugins[u"Navigator"].next(mode=u"normal", skip_children=True)<CR>')))266 self.menu + ActionEntry(u'Pre&vious Same Level', self.keybindings[-1])267 # visual mode268 self.keybindings.append(Keybinding(u'[[', Plug(u'OrgJumpToPreviousSkipChildrenVisual', u'<Esc>:<C-u>py ORGMODE.plugins[u"Navigator"].previous(mode=u"visual", skip_children=True)<CR>', mode=MODE_VISUAL)))269 self.keybindings.append(Keybinding(u']]', Plug(u'OrgJumpToNextSkipChildrenVisual', u'<Esc>:<C-u>py ORGMODE.plugins[u"Navigator"].next(mode=u"visual", skip_children=True)<CR>', mode=MODE_VISUAL)))270 # operator-pending mode271 self.keybindings.append(Keybinding(u'[[', Plug(u'OrgJumpToPreviousSkipChildrenOperator', u':<C-u>py ORGMODE.plugins[u"Navigator"].previous(mode=u"operator", skip_children=True)<CR>', mode=MODE_OPERATOR)))...

Full Screen

Full Screen

Misc.py

Source:Misc.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2import vim3from orgmode._vim import ORGMODE, apply_count4from orgmode.menu import Submenu5from orgmode.keybinding import Keybinding, Plug, MODE_VISUAL, MODE_OPERATOR6class Misc(object):7 u""" Miscellaneous functionality """8 def __init__(self):9 u""" Initialize plugin """10 object.__init__(self)11 # menu entries this plugin should create12 self.menu = ORGMODE.orgmenu + Submenu(u'Misc')13 # key bindings for this plugin14 # key bindings are also registered through the menu so only additional15 # bindings should be put in this variable16 self.keybindings = []17 @classmethod18 def jump_to_first_character(cls):19 heading = ORGMODE.get_document().current_heading()20 if not heading:21 vim.eval(u'feedkeys("^", "n")'.encode(u'utf-8'))22 return23 vim.current.window.cursor = (vim.current.window.cursor[0], heading.level + 1)24 @classmethod25 def edit_at_first_character(cls):26 heading = ORGMODE.get_document().current_heading()27 if not heading or heading.start_vim != vim.current.window.cursor[0]:28 vim.eval(u'feedkeys("I", "n")'.encode(u'utf-8'))29 return30 vim.current.window.cursor = (vim.current.window.cursor[0], heading.level + 1)31 vim.command(u'startinsert'.encode(u'utf-8'))32 #@repeat33 @classmethod34 @apply_count35 def i_heading(cls, mode=u'visual', selection=u'inner', skip_children=False):36 u"""37 inner heading text object38 """39 heading = ORGMODE.get_document().current_heading()40 if heading:41 if selection != u'inner':42 heading = heading if not heading.parent else heading.parent43 line_start, col_start = [ int(i) for i in vim.eval(u'getpos("\'<")'.encode(u'utf-8'))[1:3] ]44 line_end, col_end = [ int(i) for i in vim.eval(u'getpos("\'>")'.encode(u'utf-8'))[1:3] ]45 if mode != u'visual':46 line_start = vim.current.window.cursor[0]47 line_end = line_start48 start = line_start49 end = line_end50 move_one_character_back = u'' if mode == u'visual' else u'h'51 if heading.start_vim < line_start:52 start = heading.start_vim53 if heading.end_vim > line_end and not skip_children:54 end = heading.end_vim55 elif heading.end_of_last_child_vim > line_end and skip_children:56 end = heading.end_of_last_child_vim57 if mode != u'visual' and not vim.current.buffer[end - 1]:58 end -= 159 move_one_character_back = u''60 swap_cursor = u'o' if vim.current.window.cursor[0] == line_start else u''61 if selection == u'inner' and vim.current.window.cursor[0] != line_start:62 h = ORGMODE.get_document().current_heading()63 if h:64 heading = h65 visualmode = vim.eval(u'visualmode()').decode(u'utf-8') if mode == u'visual' else u'v'66 if line_start == start and line_start != heading.start_vim:67 if col_start in (0, 1):68 vim.command((u'normal! %dgg0%s%dgg$%s%s' % \69 (start, visualmode, end, move_one_character_back, swap_cursor)).encode(u'utf-8'))70 else:71 vim.command((u'normal! %dgg0%dl%s%dgg$%s%s' % \72 (start, col_start - 1, visualmode, end, move_one_character_back, swap_cursor)).encode(u'utf-8'))73 else:74 vim.command((u'normal! %dgg0%dl%s%dgg$%s%s' % \75 (start, heading.level + 1, visualmode, end, move_one_character_back, swap_cursor)).encode(u'utf-8'))76 if selection == u'inner':77 if mode == u'visual':78 return u'OrgInnerHeadingVisual' if not skip_children else u'OrgInnerTreeVisual'79 else:80 return u'OrgInnerHeadingOperator' if not skip_children else u'OrgInnerTreeOperator'81 else:82 if mode == u'visual':83 return u'OrgOuterHeadingVisual' if not skip_children else u'OrgOuterTreeVisual'84 else:85 return u'OrgOuterHeadingOperator' if not skip_children else u'OrgOuterTreeOperator'86 elif mode == u'visual':87 vim.command(u'normal! gv'.encode(u'utf-8'))88 #@repeat89 @classmethod90 @apply_count91 def a_heading(cls, selection=u'inner', skip_children=False):92 u"""93 a heading text object94 """95 heading = ORGMODE.get_document().current_heading()96 if heading:97 if selection != u'inner':98 heading = heading if not heading.parent else heading.parent99 line_start, col_start = [ int(i) for i in vim.eval(u'getpos("\'<")'.encode(u'utf-8'))[1:3] ]100 line_end, col_end = [ int(i) for i in vim.eval(u'getpos("\'>")'.encode(u'utf-8'))[1:3] ]101 start = line_start102 end = line_end103 if heading.start_vim < line_start:104 start = heading.start_vim105 if heading.end_vim > line_end and not skip_children:106 end = heading.end_vim107 elif heading.end_of_last_child_vim > line_end and skip_children:108 end = heading.end_of_last_child_vim109 swap_cursor = u'o' if vim.current.window.cursor[0] == line_start else u''110 vim.command((u'normal! %dgg%s%dgg$%s' % \111 (start, vim.eval(u'visualmode()'.encode(u'utf-8')), end, swap_cursor)).encode(u'utf-8'))112 if selection == u'inner':113 return u'OrgAInnerHeadingVisual' if not skip_children else u'OrgAInnerTreeVisual'114 else:115 return u'OrgAOuterHeadingVisual' if not skip_children else u'OrgAOuterTreeVisual'116 else:117 vim.command(u'normal! gv'.encode(u'utf-8'))118 def register(self):119 u"""120 Registration of plugin. Key bindings and other initialization should be done.121 """122 self.keybindings.append(Keybinding(u'^', Plug(u'OrgJumpToFirstCharacter', u':py ORGMODE.plugins[u"Misc"].jump_to_first_character()<CR>')))123 self.keybindings.append(Keybinding(u'I', Plug(u'OrgEditAtFirstCharacter', u':py ORGMODE.plugins[u"Misc"].edit_at_first_character()<CR>')))124 self.keybindings.append(Keybinding(u'ih', Plug(u'OrgInnerHeadingVisual', u':<C-u>py ORGMODE.plugins[u"Misc"].i_heading()<CR>', mode=MODE_VISUAL)))125 self.keybindings.append(Keybinding(u'ah', Plug(u'OrgAInnerHeadingVisual', u':<C-u>py ORGMODE.plugins[u"Misc"].a_heading()<CR>', mode=MODE_VISUAL)))126 self.keybindings.append(Keybinding(u'Oh', Plug(u'OrgOuterHeadingVisual', u':<C-u>py ORGMODE.plugins[u"Misc"].i_heading(selection=u"outer")<CR>', mode=MODE_VISUAL)))127 self.keybindings.append(Keybinding(u'OH', Plug(u'OrgAOuterHeadingVisual', u':<C-u>py ORGMODE.plugins[u"Misc"].a_heading(selection=u"outer")<CR>', mode=MODE_VISUAL)))128 self.keybindings.append(Keybinding(u'ih', Plug(u'OrgInnerHeadingOperator', u':<C-u>py ORGMODE.plugins[u"Misc"].i_heading(mode=u"operator")<CR>', mode=MODE_OPERATOR)))129 self.keybindings.append(Keybinding(u'ah', u':normal Vah<CR>', mode=MODE_OPERATOR))130 self.keybindings.append(Keybinding(u'Oh', Plug(u'OrgOuterHeadingOperator', ':<C-u>py ORGMODE.plugins[u"Misc"].i_heading(mode=u"operator", selection=u"outer")<CR>', mode=MODE_OPERATOR)))131 self.keybindings.append(Keybinding(u'OH', u':normal VOH<CR>', mode=MODE_OPERATOR))132 self.keybindings.append(Keybinding(u'ir', Plug(u'OrgInnerTreeVisual', u':<C-u>py ORGMODE.plugins[u"Misc"].i_heading(skip_children=True)<CR>', mode=MODE_VISUAL)))133 self.keybindings.append(Keybinding(u'ar', Plug(u'OrgAInnerTreeVisual', u':<C-u>py ORGMODE.plugins[u"Misc"].a_heading(skip_children=True)<CR>', mode=MODE_VISUAL)))134 self.keybindings.append(Keybinding(u'Or', Plug(u'OrgOuterTreeVisual', u'<:<C-u>py ORGMODE.plugins[u"Misc"].i_heading(selection=u"outer", skip_children=True)<CR>', mode=MODE_VISUAL)))135 self.keybindings.append(Keybinding(u'OR', Plug(u'OrgAOuterTreeVisual', u':<C-u>py ORGMODE.plugins[u"Misc"].a_heading(selection=u"outer", skip_children=True)<CR>', mode=MODE_VISUAL)))136 self.keybindings.append(Keybinding(u'ir', Plug(u'OrgInnerTreeOperator', u':<C-u>py ORGMODE.plugins[u"Misc"].i_heading(mode=u"operator")<CR>', mode=MODE_OPERATOR)))137 self.keybindings.append(Keybinding(u'ar', u':normal Var<CR>', mode=MODE_OPERATOR))138 self.keybindings.append(Keybinding(u'Or', Plug(u'OrgOuterTreeOperator', u':<C-u>py ORGMODE.plugins[u"Misc"].i_heading(mode=u"operator", selection=u"outer", skip_children=True)<CR>', mode=MODE_OPERATOR)))...

Full Screen

Full Screen

index.stories.js

Source:index.stories.js Github

copy

Full Screen

1import React from 'react';2import { storiesOf } from '@storybook/react';3import { action } from '@storybook/addon-actions';4import { text } from '@storybook/addon-knobs';5import Heading, { SubHeading } from '.';6const stories = storiesOf('Heading', module);7stories.add(8 'level 1',9 () => <Heading level="1">{text('text', '見出しレベル1')}</Heading>,10 { info: '見出しレベル1' },11);12stories.add(13 'level 1 with sub heading',14 () => (15 <Heading level="1">16 {text('text', '見出しレベル1 ')}17 <SubHeading>{text('sub', '小見出し')}</SubHeading>18 </Heading>19 ),20 { info: '見出しレベル1' },21);22stories.add(23 'level 2',24 () => <Heading level="2">{text('text', '見出しレベル2')}</Heading>,25 { info: '見出しレベル2' },26);27stories.add(28 'level 2 with sub heading',29 () => (30 <Heading level="2">31 {text('text', '見出しレベル2 ')}32 <SubHeading>{text('sub', '小見出し')}</SubHeading>33 </Heading>34 ),35 { info: '見出しレベル2' },36);37stories.add(38 'level 3',39 () => <Heading level="3">{text('text', '見出しレベル3')}</Heading>,40 { info: '見出しレベル3' },41);42stories.add(43 'level 3 with sub heading',44 () => (45 <Heading level="3">46 {text('text', '見出しレベル3 ')}47 <SubHeading>{text('sub', '小見出し')}</SubHeading>48 </Heading>49 ),50 { info: '見出しレベル3' },51);52stories.add(53 'level 4',54 () => <Heading level="4">{text('text', '見出しレベル4')}</Heading>,55 { info: '見出しレベル4' },56);57stories.add(58 'level 4 with sub heading',59 () => (60 <Heading level="4">61 {text('text', '見出しレベル4 ')}62 <SubHeading>{text('sub', '小見出し')}</SubHeading>63 </Heading>64 ),65 { info: '見出しレベル4' },66);67stories.add(68 'level 5',69 () => <Heading level="5">{text('text', '見出しレベル5')}</Heading>,70 { info: '見出しレベル5' },71);72stories.add(73 'level 5 with sub heading',74 () => (75 <Heading level="5">76 {text('text', '見出しレベル5 ')}77 <SubHeading>{text('sub', '小見出し')}</SubHeading>78 </Heading>79 ),80 { info: '見出しレベル5' },81);82stories.add(83 'level 6',84 () => <Heading level="6">{text('text', '見出しレベル6')}</Heading>,85 { info: '見出しレベル6' },86);87stories.add(88 'level 6 with sub heading',89 () => (90 <Heading level="6">91 {text('text', '見出しレベル6 ')}92 <SubHeading>{text('sub', '小見出し')}</SubHeading>93 </Heading>94 ),95 { info: '見出しレベル6' },...

Full Screen

Full Screen

heading.stories.js

Source:heading.stories.js Github

copy

Full Screen

1import React from "react"2import { text } from "@storybook/addon-knobs"3import Heading from "./heading"4import knobData from "./heading.knobs.json"5const { headingText } = knobData6export const allHeadings = () => (7 <>8 <Heading level={1}>9 {text(headingText.label, headingText.default, headingText.group)}10 </Heading>11 <Heading level={2}>12 {text(headingText.label, headingText.default, headingText.group)}13 </Heading>14 <Heading level={3}>15 {text(headingText.label, headingText.default, headingText.group)}16 </Heading>17 <Heading level={4}>18 {text(headingText.label, headingText.default, headingText.group)}19 </Heading>20 <Heading level={5}>21 {text(headingText.label, headingText.default, headingText.group)}22 </Heading>23 <Heading level={6}>24 {text(headingText.label, headingText.default, headingText.group)}25 </Heading>26 </>27)28export const levelOne = () => (29 <Heading level={1}>30 {text(headingText.label, headingText.default, headingText.group)}31 </Heading>32)33export const levelTwo = () => (34 <Heading level={2}>35 {text(headingText.label, headingText.default, headingText.group)}36 </Heading>37)38export const levelThree = () => (39 <Heading level={3}>40 {text(headingText.label, headingText.default, headingText.group)}41 </Heading>42)43export const levelFour = () => (44 <Heading level={4}>45 {text(headingText.label, headingText.default, headingText.group)}46 </Heading>47)48export const levelFive = () => (49 <Heading level={5}>50 {text(headingText.label, headingText.default, headingText.group)}51 </Heading>52)53export const levelSix = () => (54 <Heading level={6}>55 {text(headingText.label, headingText.default, headingText.group)}56 </Heading>57)58export default {59 component: Heading,60 title: `Atoms/Heading`,...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Heading } from 'storybook-root-decorator';2<Heading level={1}>Heading 1</Heading>3<Heading level={2}>Heading 2</Heading>4<Heading level={3}>Heading 3</Heading>5<Heading level={4}>Heading 4</Heading>6<Heading level={5}>Heading 5</Heading>7<Heading level={6}>Heading 6</Heading>8import { addDecorator } from '@storybook/react';9import { withRootDecorator } from 'storybook-root-decorator';10addDecorator(withRootDecorator);11import { Heading } from 'storybook-root-decorator';12<Heading level={1}>Heading 1</Heading>13<Heading level={2}>Heading 2</Heading>14<Heading level={3}>Heading 3</Heading>15<Heading level={4}>Heading 4</Heading>16<Heading level={5}>Heading 5</Heading>17<Heading level={6}>Heading 6</Heading>18MIT © [davidcostadev](

Full Screen

Using AI Code Generation

copy

Full Screen

1import React from 'react';2import { storiesOf } from '@storybook/react';3import Heading from 'storybook-root-decorator';4storiesOf('Heading', module)5 .add('with text', () => (6 ));

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Heading } from 'storybook-root-decorator';2import { Heading } from 'storybook-root-decorator';3import { Heading } from 'storybook-root-decorator';4storiesOf('Button', module)5 .addDecorator(Heading('Button'))6 .add('with text', () => (7 <Button onClick={action('clicked')}>Hello Button</Button>8 .add('with some emoji', () => (9 <Button onClick={action('clicked')}>10 ));11MIT © [vishalv971](

Full Screen

Using AI Code Generation

copy

Full Screen

1import React from "react";2import { Heading } from "storybook-root-decorator";3export default {4};5export const h1 = () => <Heading.h1>Heading 1</Heading.h1>;6export const h2 = () => <Heading.h2>Heading 2</Heading.h2>;7export const h3 = () => <Heading.h3>Heading 3</Heading.h3>;8export const h4 = () => <Heading.h4>Heading 4</Heading.h4>;9export const h5 = () => <Heading.h5>Heading 5</Heading.h5>;10export const h6 = () => <Heading.h6>Heading 6</Heading.h6>;

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Heading } from 'storybook-root-decorator';2storiesOf('Heading', module)3 .add('with text', () => (4import { configure, addDecorator } from '@storybook/react';5import { withRootDecorator } from 'storybook-root-decorator';6addDecorator(withRootDecorator);7configure(require.context('../src', true, /\.stories\.js$/), module);8const path = require('path');9module.exports = (baseConfig, env, config) => {10 config.resolve.alias = {11 'storybook-root-decorator': path.resolve(__dirname, '../'),12 };13 return config;14};15import '@storybook/addon-actions/register';16import '@storybook/addon-links/register';17import 'storybook-root-decorator/register';18import { withRootDecorator } from 'storybook-root-decorator';19export const decorators = [withRootDecorator];20### withRootDecorator(options)

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Heading } from "storybook-root";2export default function Test() {3 return <Heading>Test</Heading>;4}5import { addDecorator } from "@storybook/react";6import { withNextRouter } from "storybook-addon-next-router";7const withGlobal = (Story) => (8);9addDecorator(withNextRouter());10addDecorator(withGlobal);11MIT © [davidjamesstone](

Full Screen

Using AI Code Generation

copy

Full Screen

1import Heading from 'storybook-root-decorator';2export default {3};4export const heading = () => <Heading />;5import React from 'react';6import { addDecorator } from '@storybook/react';7import { withA11y } from '@storybook/addon-a11y';8import { withKnobs } from '@storybook/addon-knobs';9import { withInfo } from '@storybook/addon-info';10import { withRootDecorator } from 'storybook-root-decorator';11addDecorator(withA11y);12addDecorator(withKnobs);13addDecorator(withInfo);14addDecorator(withRootDecorator);15module.exports = ({ config }) => {16 config.resolve.modules.push(`${process.cwd()}/src`);17 return config;18};19import Heading from 'storybook-root-decorator';20export default {21};22export const heading = () => <Heading />;23import React from 'react';24import { addDecorator } from '@storybook/react';25import { withA11y } from '@storybook/addon-a11y';26import { withKnobs } from '@storybook/addon-knobs';27import { withInfo } from '@storybook/addon-info';28import { withRootDecorator } from 'storybook-root-decorator';29addDecorator(withA11y);30addDecorator(withKnobs);31addDecorator(withInfo);32addDecorator(withRootDecorator);33module.exports = ({ config }) => {34 config.resolve.modules.push(`${process.cwd()}/src`);35 return config;36};

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run storybook-root automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful