| 1 |
/* ************************************************************************ */ |
| 2 |
/* */ |
| 3 |
/* This file is part of Frama-C. */ |
| 4 |
/* */ |
| 5 |
/* Copyright (C) 2007-2022 */ |
| 6 |
/* CEA (Commissariat à l'énergie atomique et aux énergies */ |
| 7 |
/* alternatives) */ |
| 8 |
/* */ |
| 9 |
/* you can redistribute it and/or modify it under the terms of the GNU */ |
| 10 |
/* Lesser General Public License as published by the Free Software */ |
| 11 |
/* Foundation, version 2.1. */ |
| 12 |
/* */ |
| 13 |
/* It is distributed in the hope that it will be useful, */ |
| 14 |
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ |
| 15 |
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ |
| 16 |
/* GNU Lesser General Public License for more details. */ |
| 17 |
/* */ |
| 18 |
/* See the GNU Lesser General Public License version 2.1 */ |
| 19 |
/* for more details (enclosed in the file licenses/LGPLv2.1). */ |
| 20 |
/* */ |
| 21 |
/* ************************************************************************ */ |
| 22 |
|
| 23 |
// -------------------------------------------------------------------------- |
| 24 |
// --- Text Pages |
| 25 |
// -------------------------------------------------------------------------- |
| 26 |
|
| 27 |
/** |
| 28 |
A collection of text area and elements do render textual content. |
| 29 |
|
| 30 |
Inside such areas, all elements are styled like a classical web page. |
| 31 |
All elements are encapsulated inside a `<div>` with `'dome-pages'` |
| 32 |
class name, which can be used in your CSS selectors. |
| 33 |
|
| 34 |
All the textual parts are selectable inside the page, contrarily to |
| 35 |
most other widget components. |
| 36 |
|
| 37 |
The behaviour of `<a href=...>` elements differs for local links and |
| 38 |
external URLs. Local links trigger a `'dome.href'` event, that |
| 39 |
you can listen to from the originating renderer process, _eg. by |
| 40 |
using `Dome.useUpdate()` custom hook. |
| 41 |
|
| 42 |
External links launch the user's default browser. |
| 43 |
|
| 44 |
@packageDocumentation |
| 45 |
@module dome/text/pages |
| 46 |
*/ |
| 47 |
|
| 48 |
import React from 'react'; |
| 49 |
import { classes } from 'dome/misc/utils'; |
| 50 |
import './style.css'; |
| 51 |
|
| 52 |
export interface TextProps { |
| 53 |
/** Additional classe(s). */ |
| 54 |
className?: string; |
| 55 |
/** Additional style properties. */ |
| 56 |
style?: React.CSSProperties; |
| 57 |
/** Inner Components. */ |
| 58 |
children?: React.ReactNode; |
| 59 |
} |
| 60 |
|
| 61 |
// -------------------------------------------------------------------------- |
| 62 |
// --- Page |
| 63 |
// -------------------------------------------------------------------------- |
| 64 |
|
| 65 |
/** |
| 66 |
Blank HTML page. |
| 67 |
|
| 68 |
The page has insets and shadows and fills the entire available area. |
| 69 |
Large content is crolled inside in both directions. |
| 70 |
*/ |
| 71 |
export const Page = (props: TextProps): JSX.Element => ( |
| 72 |
<div className="dome-xPages-page"> |
| 73 |
<div |
| 74 |
className={classes('dome-xPages-sheet dome-pages', props.className)} |
| 75 |
style={props.style} |
| 76 |
> |
| 77 |
{props.children} |
| 78 |
</div> |
| 79 |
</div> |
| 80 |
); |
| 81 |
|
| 82 |
// -------------------------------------------------------------------------- |
| 83 |
// --- Note |
| 84 |
// -------------------------------------------------------------------------- |
| 85 |
|
| 86 |
/** |
| 87 |
Blank HTML textarea. |
| 88 |
|
| 89 |
The area has small padding and no margin, and does not scroll its content. |
| 90 |
*/ |
| 91 |
export const Note = (props: TextProps): JSX.Element => ( |
| 92 |
<div |
| 93 |
className={classes('dome-xPages-note', 'dome-pages', props.className)} |
| 94 |
style={props.style} |
| 95 |
> |
| 96 |
{props.children} |
| 97 |
</div> |
| 98 |
); |
| 99 |
|
| 100 |
// -------------------------------------------------------------------------- |