Skip to content

Commit 3ca18cf

Browse files
committed
wip: Sanitize options for both terminal and non-terminal boxes #111
1 parent d8bc7eb commit 3ca18cf

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

py/demo/custom_layout.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121

2222
def main(view: View):
23-
name = view(box('What is your name?', value='Boaty McBoatface'), ['Continue'])
24-
feel = view(box(f'How do you feel today, {name}?', value='intrigued'), ['Continue'])
23+
name, _ = view(box('What is your name?', value='Boaty McBoatface'), ['Continue'])
24+
feel, _ = view(box(f'How do you feel today, {name}?', value='intrigued'), ['Continue'])
2525
view(f'What a coincidence, {name}, I feel {feel}, too!')
2626

2727

@@ -78,15 +78,12 @@ def main(view: View):
7878
box('Open user menu') / 'sr-only',
7979
box(
8080
box('B') / 'text-white text-lg font-light',
81+
mode='more',
82+
options=['Profile', 'Settings', 'Sign Out'],
8183
) / 'flex items-center justify-center h-8 w-8 rounded-full bg-pink-500',
84+
mode='input',
8285
) / 'flex rounded-full bg-indigo-600 text-sm text-white focus:outline-none focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-offset-indigo-600',
8386
),
84-
# Profile menu
85-
box(
86-
box('Profile') / 'block py-2 px-4 text-sm text-gray-700',
87-
box('Settings') / 'block py-2 px-4 text-sm text-gray-700',
88-
box('Sign out') / 'block py-2 px-4 text-sm text-gray-700',
89-
) / 'absolute right-0 z-10 mt-2 w-48 origin-top-right rounded-md bg-white py-1 shadow-lg ring-1 ring-black focus:outline-none',
9087
) / 'relative ml-3 shrink-0',
9188
) / 'flex items-center',
9289
) / 'hidden lg:ml-4 lg:block',

web/src/heuristics.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,11 @@ export const sanitizeBox = (formatter: Formatter, box: Box): Box => {
270270
const fmt = box.locale ? formatter.load(box.locale) : formatter
271271

272272
let mdHasLinks = false
273+
if (box.options) box.options = sanitizeOptions(box.options)
273274
if (box.items) {
274275
box.items = box.items.map(b => sanitizeBox(fmt, b))
275276
} else {
276-
const { value, options } = box
277-
278-
if (options) box.options = sanitizeOptions(options)
277+
const { value } = box
279278

280279
sanitizeRange(box)
281280

0 commit comments

Comments
 (0)