Of course, the Nenav's configuration isn't only with data
and dataFunc
, you can personalize it much more.
Change style
Nenav has inside two configuration for its style, one for Zurb Foundation and one for Twitter Bootstrap.
You can set them with the property style='foundation'
or style='bootstrap'
. You can also build your own style following this example ( the foundation's configuration ):
const exampleStyle = {
main_area: "small-12",
link: '',
navbar: {
area: "small-12",
btn: "primary button",
btn_group: "small button-group"
},
folder_view: {
table: "table-scroll hover",
name: 'text-left',
type: 'text-right',
size: 'text-right',
date: 'text-center'
},
file: {
main_area: 'callout',
pre: 'prettyprint',
date: 'subheader'
},
icon: {
file: 'fi-page',
folder: 'fi-folder',
arrow_up: 'fi-arrow-up',
arrow_down: 'fi-arrow-down',
back: 'float-right fi-x'
}
};
After you will use it with style={exampleStyle}
.
Change initial path
You can set the initial path with: path='/my/path/sub_dir'
.
Change initial sort
You can set also the initial sort with an object like this: { attr: attribute, type: sort_type }
. attribute
can be one of this name, type, size, date and sort_type
can be asc or desc.
Add a function when file is shown
When a user open a file Nenav show it instead of the files list. When this action was executed you can specify a function to call ( example to highlight syntax with prettify ) in this way: fileMountFunc={my_function}
Summary
Inside the demo was used this configuration:
const nenav_conf = {
path: '/src',
data: path_data,
data_sort: { attr: 'name', type: 'asc' },
dataFunc: getFileData,
fileMountFunc: PR.prettyPrint,
style: 'foundation'
};
You can pass it to Nenav Component with: <Nenav {...nenav_conf} />
.
Note: When you want only the root path you don't have to use /
but an empty string.
Default configuration
const initState = {
path: '',
style: foundationStyle,
data: { data: {} },
data_sort: {
attr: 'type',
type: 'asc'
},
dataFunc: console.log,
list_type: 'dir',
file_info: null,
onMount: null
};